Merge pull request #79 from coien/master
Thank you for the contribution.
diff --git a/crypto/cipher/aes_icm.c b/crypto/cipher/aes_icm.c
index 4e4d254..6f32d2f 100644
--- a/crypto/cipher/aes_icm.c
+++ b/crypto/cipher/aes_icm.c
@@ -337,11 +337,6 @@
}
}
-static inline void aes_icm_advance(aes_icm_ctx_t *c) {
- aes_icm_advance_ismacryp(c, 0);
-}
-
-
/*e
* icm_encrypt deals with the following cases:
*
diff --git a/crypto/cipher/aes_icm_ossl.c b/crypto/cipher/aes_icm_ossl.c
index b2e3ce1..db3b944 100644
--- a/crypto/cipher/aes_icm_ossl.c
+++ b/crypto/cipher/aes_icm_ossl.c
@@ -221,12 +221,16 @@
* the salt is unpredictable (but not necessarily secret) data which
* randomizes the starting point in the keystream
*/
-err_status_t aes_icm_openssl_context_init (aes_icm_ctx_t *c, const uint8_t *key)
+err_status_t aes_icm_openssl_context_init (aes_icm_ctx_t *c, const uint8_t *key, int len)
{
/*
* set counter and initial values to 'offset' value, being careful not to
* go past the end of the key buffer
*/
+
+ if (c->key_size + SALT_SIZE != len)
+ return err_status_bad_param;
+
v128_set_to_zero(&c->counter);
v128_set_to_zero(&c->offset);
memcpy(&c->counter, key + c->key_size, SALT_SIZE);
@@ -325,6 +329,11 @@
return err_status_ok;
}
+uint16_t aes_icm_bytes_encrypted(aes_icm_ctx_t *c)
+{
+ return htons(c->counter.v16[7]);
+}
+
/*
* Name of this crypto engine
*/
diff --git a/crypto/include/aes_icm_ossl.h b/crypto/include/aes_icm_ossl.h
index 89da7e0..90ec954 100644
--- a/crypto/include/aes_icm_ossl.h
+++ b/crypto/include/aes_icm_ossl.h
@@ -67,6 +67,9 @@
} aes_icm_ctx_t;
err_status_t aes_icm_openssl_set_iv(aes_icm_ctx_t *c, void *iv, int dir);
+err_status_t aes_icm_openssl_context_init(aes_icm_ctx_t *c, const uint8_t *key, int len);
+err_status_t aes_icm_output(aes_icm_ctx_t *c, uint8_t *buffer, int num_octets_to_output);
+uint16_t aes_icm_bytes_encrypted(aes_icm_ctx_t *c);
#endif /* AES_ICM_H */
diff --git a/crypto/include/sha1.h b/crypto/include/sha1.h
index fd54469..84d1c65 100644
--- a/crypto/include/sha1.h
+++ b/crypto/include/sha1.h
@@ -68,18 +68,18 @@
*
*/
-void inline sha1_init (sha1_ctx_t *ctx)
+inline void sha1_init (sha1_ctx_t *ctx)
{
EVP_MD_CTX_init(ctx);
EVP_DigestInit(ctx, EVP_sha1());
}
-void inline sha1_update (sha1_ctx_t *ctx, const uint8_t *M, int octets_in_msg)
+inline void sha1_update (sha1_ctx_t *ctx, const uint8_t *M, int octets_in_msg)
{
EVP_DigestUpdate(ctx, M, octets_in_msg);
}
-void inline sha1_final (sha1_ctx_t *ctx, uint32_t *output)
+inline void sha1_final (sha1_ctx_t *ctx, uint32_t *output)
{
unsigned int len = 0;