File: hmac_sha2.c

package info (click to toggle)
openswan 1%3A2.4.6%2Bdfsg.2-1.1%2Betch2
  • links: PTS
  • area: main
  • in suites: etch
  • size: 25,000 kB
  • ctags: 16,877
  • sloc: ansic: 121,112; sh: 19,782; xml: 9,699; asm: 4,422; perl: 4,087; makefile: 3,367; tcl: 713; exp: 657; yacc: 396; pascal: 328; lex: 289; sed: 265; awk: 124; lisp: 3
file content (32 lines) | stat: -rw-r--r-- 946 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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)