Commit 99377bdd authored by Sergey Lyubka's avatar Sergey Lyubka Committed by Cesanta Bot

Fix user registration flow

PUBLISHED_FROM=bac8c10063215f7f7163f607213d15a3c5f81552
parent c6b5343c
...@@ -805,7 +805,8 @@ double cs_time(void) { ...@@ -805,7 +805,8 @@ double cs_time(void) {
/* Amalgamated: #include "common/md5.h" */ /* Amalgamated: #include "common/md5.h" */
#if !DISABLE_MD5 && !defined(EXCLUDE_COMMON) #if !defined(EXCLUDE_COMMON)
#if !DISABLE_MD5
/* Amalgamated: #include "common/cs_endian.h" */ /* Amalgamated: #include "common/cs_endian.h" */
...@@ -992,21 +993,7 @@ void MD5_Final(unsigned char digest[16], MD5_CTX *ctx) { ...@@ -992,21 +993,7 @@ void MD5_Final(unsigned char digest[16], MD5_CTX *ctx) {
memcpy(digest, ctx->buf, 16); memcpy(digest, ctx->buf, 16);
memset((char *) ctx, 0, sizeof(*ctx)); memset((char *) ctx, 0, sizeof(*ctx));
} }
#endif /* DISABLE_MD5 */
/*
* Stringify binary data. Output buffer size must be 2 * size_of_input + 1
* because each byte of input takes 2 bytes in string representation
* plus 1 byte for the terminating \0 character.
*/
void cs_to_hex(char *to, const unsigned char *p, size_t len) {
static const char *hex = "0123456789abcdef";
for (; len--; p++) {
*to++ = hex[p[0] >> 4];
*to++ = hex[p[0] & 0x0f];
}
*to = '\0';
}
char *cs_md5(char buf[33], ...) { char *cs_md5(char buf[33], ...) {
unsigned char hash[16]; unsigned char hash[16];
...@@ -1736,6 +1723,36 @@ char *strdup(const char *src) { ...@@ -1736,6 +1723,36 @@ char *strdup(const char *src) {
} }
#endif #endif
void cs_to_hex(char *to, const unsigned char *p, size_t len) {
static const char *hex = "0123456789abcdef";
for (; len--; p++) {
*to++ = hex[p[0] >> 4];
*to++ = hex[p[0] & 0x0f];
}
*to = '\0';
}
static int fourbit(int ch) {
if (ch >= '0' && ch <= '9') {
return ch - '0';
} else if (ch >= 'a' && ch <= 'f') {
return ch - 'a' + 10;
} else if (ch >= 'A' && ch <= 'F') {
return ch - 'A' + 10;
}
return 0;
}
void cs_from_hex(char *to, const char *p, size_t len) {
size_t i;
for (i = 0; i < len; i += 2) {
*to++ = (fourbit(p[i]) << 4) + fourbit(p[i + 1]);
}
*to = '\0';
}
#endif /* EXCLUDE_COMMON */ #endif /* EXCLUDE_COMMON */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
#line 1 "mongoose/src/net.c" #line 1 "mongoose/src/net.c"
......
...@@ -1485,13 +1485,6 @@ void MD5_Final(unsigned char *md, MD5_CTX *c); ...@@ -1485,13 +1485,6 @@ void MD5_Final(unsigned char *md, MD5_CTX *c);
*/ */
char *cs_md5(char buf[33], ...); char *cs_md5(char buf[33], ...);
/*
* Stringify binary data. Output buffer size must be 2 * size_of_input + 1
* because each byte of input takes 2 bytes in string representation
* plus 1 byte for the terminating \0 character.
*/
void cs_to_hex(char *to, const unsigned char *p, size_t len);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
...@@ -1573,6 +1566,19 @@ int c_vsnprintf(char *buf, size_t buf_size, const char *format, va_list ap); ...@@ -1573,6 +1566,19 @@ int c_vsnprintf(char *buf, size_t buf_size, const char *format, va_list ap);
*/ */
const char *c_strnstr(const char *s, const char *find, size_t slen); const char *c_strnstr(const char *s, const char *find, size_t slen);
/*
* Stringify binary data. Output buffer size must be 2 * size_of_input + 1
* because each byte of input takes 2 bytes in string representation
* plus 1 byte for the terminating \0 character.
*/
void cs_to_hex(char *to, const unsigned char *p, size_t len);
/*
* Convert stringified binary data back to binary.
* Does the reverse of `cs_to_hex()`.
*/
void cs_from_hex(char *to, const char *p, size_t len);
/* /*
* ARM C Compiler doesn't have strdup, so we provide it * ARM C Compiler doesn't have strdup, so we provide it
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment