Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
223a9367
Commit
223a9367
authored
Jun 05, 2015
by
Johny Mattsson
Browse files
Switched crypto module to use ROM SHA1/MD5.
Also disabled MD2 support by default (see MD2_ENABLE in user_config.h).
parent
d855584b
Changes
3
Show whitespace changes
Inline
Side-by-side
app/crypto/digests.c
View file @
223a9367
...
...
@@ -29,35 +29,43 @@
*/
#include "digests.h"
#include "user_config.h"
#include "rom.h"
#include "lwip/mem.h"
#include "lwip/arch.h"
#include "ssl/ssl_crypto.h"
#include "sha2.h"
#include <string.h>
#include <c_errno.h>
#ifdef MD2_ENABLE
#include "ssl/ssl_crypto.h"
#endif
#ifdef SHA2_ENABLE
#include "sha2.h"
#endif
typedef
char
ensure_int_and_size_t_same
[(
sizeof
(
int
)
==
sizeof
(
size_t
))
?
0
:
-
1
];
/* None of the functions match the prototype fully due to the void *, and in
some cases also the int vs size_t len, so wrap declarations in a macro. */
#define MECH(pfx, ds, bs) \
#define MECH(pfx,
u,
ds, bs) \
{ #pfx, \
(create_ctx_fn)pfx ##
_
Init, \
(update_ctx_fn)pfx ##
_
Update, \
(finalize_ctx_fn)pfx ##
_
Final, \
(create_ctx_fn)pfx ##
u ##
Init, \
(update_ctx_fn)pfx ##
u ##
Update, \
(finalize_ctx_fn)pfx ##
u ##
Final, \
sizeof(pfx ## _CTX), \
ds, \
bs }
static
const
digest_mech_info_t
hash_mechs
[]
=
{
MECH
(
MD2
,
MD2_SIZE
,
16
)
,
MECH
(
MD5
,
MD5_SIZE
,
64
)
,
MECH
(
SHA1
,
SHA1_SIZE
,
64
)
#ifdef MD2_ENABLE
MECH
(
MD2
,
_
,
MD2_SIZE
,
16
),
#endif
MECH
(
MD5
,
,
MD5_DIGEST_LENGTH
,
64
)
,
MECH
(
SHA1
,
,
SHA1_DIGEST_LENGTH
,
64
)
#ifdef SHA2_ENABLE
,
MECH
(
SHA256
,
SHA256_DIGEST_LENGTH
,
SHA256_BLOCK_LENGTH
)
,
MECH
(
SHA384
,
SHA384_DIGEST_LENGTH
,
SHA384_BLOCK_LENGTH
)
,
MECH
(
SHA512
,
SHA512_DIGEST_LENGTH
,
SHA512_BLOCK_LENGTH
)
,
MECH
(
SHA256
,
_
,
SHA256_DIGEST_LENGTH
,
SHA256_BLOCK_LENGTH
)
,
MECH
(
SHA384
,
_
,
SHA384_DIGEST_LENGTH
,
SHA384_BLOCK_LENGTH
)
,
MECH
(
SHA512
,
_
,
SHA512_DIGEST_LENGTH
,
SHA512_BLOCK_LENGTH
)
#endif
};
...
...
app/include/rom.h
View file @
223a9367
...
...
@@ -15,6 +15,20 @@ extern void SHA1Init(SHA1_CTX *);
extern
void
SHA1Final
(
uint8_t
[
SHA1_DIGEST_LENGTH
],
SHA1_CTX
*
);
extern
void
SHA1Update
(
SHA1_CTX
*
,
const
uint8_t
*
,
unsigned
int
);
// MD5 is assumed to match the NetBSD md5.h header
#define MD5_DIGEST_LENGTH 16
typedef
struct
{
uint32_t
state
[
5
];
uint32_t
count
[
2
];
uint8_t
buffer
[
64
];
}
MD5_CTX
;
extern
void
MD5Init
(
MD5_CTX
*
);
extern
void
MD5Update
(
MD5_CTX
*
,
const
unsigned
char
*
,
unsigned
int
);
extern
void
MD5Final
(
unsigned
char
[
MD5_DIGEST_LENGTH
],
MD5_CTX
*
);
// base64_encode/decode derived by Cal
// Appears to match base64.h from netbsd wpa utils.
extern
unsigned
char
*
base64_encode
(
const
unsigned
char
*
src
,
size_t
len
,
size_t
*
out_len
);
...
...
app/include/user_config.h
View file @
223a9367
...
...
@@ -41,6 +41,7 @@
#define CLIENT_SSL_ENABLE
#define GPIO_INTERRUPT_ENABLE
//#define MD2_ENABLE
#define SHA2_ENABLE
// #define BUILD_WOFS 1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment