aboutsummaryrefslogtreecommitdiffstats
path: root/src/libfreeswan/libcrypto/libsha2/hmac_sha2.c
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2006-05-10 07:32:34 +0000
committerMartin Willi <martin@strongswan.org>2006-05-10 07:32:34 +0000
commitbc4a07a0adc9e31af75576477fbed488c31edaa4 (patch)
tree82a8ba5612c448b8db585b437fbbe38ef243a0ba /src/libfreeswan/libcrypto/libsha2/hmac_sha2.c
parent37a2b616e28649b6db7c87e96b375ba1176b52cc (diff)
downloadstrongswan-bc4a07a0adc9e31af75576477fbed488c31edaa4.tar.bz2
strongswan-bc4a07a0adc9e31af75576477fbed488c31edaa4.tar.xz
- started to rebuild source layout
Diffstat (limited to 'src/libfreeswan/libcrypto/libsha2/hmac_sha2.c')
-rw-r--r--src/libfreeswan/libcrypto/libsha2/hmac_sha2.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/libfreeswan/libcrypto/libsha2/hmac_sha2.c b/src/libfreeswan/libcrypto/libsha2/hmac_sha2.c
new file mode 100644
index 000000000..ad107eb62
--- /dev/null
+++ b/src/libfreeswan/libcrypto/libsha2/hmac_sha2.c
@@ -0,0 +1,32 @@
+#ifdef __KERNEL__
+#include <linux/types.h>
+#include <linux/string.h>
+#else
+#include <sys/types.h>
+#include <string.h>
+#endif
+#include "hmac_generic.h"
+#include "sha2.h"
+#include "hmac_sha2.h"
+
+void inline sha256_result(sha256_context *ctx, u_int8_t * hash, int hashlen) {
+ sha256_final(ctx);
+ memcpy(hash, &ctx->sha_out[0], hashlen);
+}
+void inline sha512_result(sha512_context *ctx, u_int8_t * hash, int hashlen) {
+ sha512_final(ctx);
+ memcpy(hash, &ctx->sha_out[0], hashlen);
+}
+HMAC_SET_KEY_IMPL (sha256_hmac_set_key,
+ sha256_hmac_context, SHA256_BLOCKSIZE,
+ sha256_init, sha256_write)
+HMAC_HASH_IMPL (sha256_hmac_hash,
+ sha256_hmac_context, sha256_context, SHA256_HASHLEN,
+ sha256_write, sha256_result)
+
+HMAC_SET_KEY_IMPL (sha512_hmac_set_key,
+ sha512_hmac_context, SHA512_BLOCKSIZE,
+ sha512_init, sha512_write)
+HMAC_HASH_IMPL (sha512_hmac_hash,
+ sha512_hmac_context, sha512_context, SHA512_HASHLEN,
+ sha512_write, sha512_result)