summaryrefslogtreecommitdiff
path: root/ecp/src/ecp/crypto/crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'ecp/src/ecp/crypto/crypto.c')
-rw-r--r--ecp/src/ecp/crypto/crypto.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/ecp/src/ecp/crypto/crypto.c b/ecp/src/ecp/crypto/crypto.c
index 1b801ab..95598da 100644
--- a/ecp/src/ecp/crypto/crypto.c
+++ b/ecp/src/ecp/crypto/crypto.c
@@ -133,8 +133,16 @@ void ecp_hmac(unsigned char *hd, ecp_hmac_key_t *k, unsigned char *m, size_t ml)
SHA1_Final(hd, &ctx);
}
+void ecp_hash(unsigned char *hd, unsigned char *m, size_t ml) {
+ SHA_CTX ctx;
+
+ SHA1_Init(&ctx);
+ SHA1_Update(&ctx, m, ml);
+ SHA1_Final(hd, &ctx);
+}
+
int ecp_str2key(uint8_t *key, char *str) {
- unsigned int u[8];
+ uint32_t u[8];
int i, rv;
if (str[ECP_SIZE_ECDH_KEY_BUF - 1] != '\0') return ECP_ERR;
@@ -154,14 +162,14 @@ int ecp_str2key(uint8_t *key, char *str) {
}
void ecp_key2str(char *str, uint8_t *key) {
- unsigned int u[8];
+ uint32_t u[8];
int i;
for (i=0; i<8; i++) {
- u[i] = (unsigned int)key[0] << 24;
- u[i] |= (unsigned int)key[1] << 16;
- u[i] |= (unsigned int)key[2] << 8;
- u[i] |= (unsigned int)key[3];
+ u[i] = (uint32_t)key[0] << 24;
+ u[i] |= (uint32_t)key[1] << 16;
+ u[i] |= (uint32_t)key[2] << 8;
+ u[i] |= (uint32_t)key[3];
key += 4;
}