| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: sha2.c,v 1.1 2013/03/16 07:32:35 agc Exp $ */ | | 1 | /* $NetBSD: sha2.c,v 1.2 2013/03/24 16:48:17 joerg Exp $ */ |
2 | /* $KAME: sha2.c,v 1.9 2003/07/20 00:28:38 itojun Exp $ */ | | 2 | /* $KAME: sha2.c,v 1.9 2003/07/20 00:28:38 itojun Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * sha2.c | | 5 | * sha2.c |
6 | * | | 6 | * |
7 | * Version 1.0.0beta1 | | 7 | * Version 1.0.0beta1 |
8 | * | | 8 | * |
9 | * Written by Aaron D. Gifford <me@aarongifford.com> | | 9 | * Written by Aaron D. Gifford <me@aarongifford.com> |
10 | * | | 10 | * |
11 | * Copyright 2000 Aaron D. Gifford. All rights reserved. | | 11 | * Copyright 2000 Aaron D. Gifford. All rights reserved. |
12 | * | | 12 | * |
13 | * Redistribution and use in source and binary forms, with or without | | 13 | * Redistribution and use in source and binary forms, with or without |
14 | * modification, are permitted provided that the following conditions | | 14 | * modification, are permitted provided that the following conditions |
| @@ -271,50 +271,26 @@ static const uint64_t sha384_initial_has | | | @@ -271,50 +271,26 @@ static const uint64_t sha384_initial_has |
271 | | | 271 | |
272 | /* Initial hash value H for SHA-512 */ | | 272 | /* Initial hash value H for SHA-512 */ |
273 | static const uint64_t sha512_initial_hash_value[8] = { | | 273 | static const uint64_t sha512_initial_hash_value[8] = { |
274 | 0x6a09e667f3bcc908ULL, | | 274 | 0x6a09e667f3bcc908ULL, |
275 | 0xbb67ae8584caa73bULL, | | 275 | 0xbb67ae8584caa73bULL, |
276 | 0x3c6ef372fe94f82bULL, | | 276 | 0x3c6ef372fe94f82bULL, |
277 | 0xa54ff53a5f1d36f1ULL, | | 277 | 0xa54ff53a5f1d36f1ULL, |
278 | 0x510e527fade682d1ULL, | | 278 | 0x510e527fade682d1ULL, |
279 | 0x9b05688c2b3e6c1fULL, | | 279 | 0x9b05688c2b3e6c1fULL, |
280 | 0x1f83d9abfb41bd6bULL, | | 280 | 0x1f83d9abfb41bd6bULL, |
281 | 0x5be0cd19137e2179ULL | | 281 | 0x5be0cd19137e2179ULL |
282 | }; | | 282 | }; |
283 | | | 283 | |
284 | #if !defined(_KERNEL) && !defined(_STANDALONE) | | | |
285 | #if defined(__weak_alias) | | | |
286 | __weak_alias(SHA224_Init,_SHA224_Init) | | | |
287 | __weak_alias(SHA224_Update,_SHA224_Update) | | | |
288 | __weak_alias(SHA224_Final,_SHA224_Final) | | | |
289 | __weak_alias(SHA224_Transform,_SHA224_Transform) | | | |
290 | | | | |
291 | __weak_alias(SHA256_Init,_SHA256_Init) | | | |
292 | __weak_alias(SHA256_Update,_SHA256_Update) | | | |
293 | __weak_alias(SHA256_Final,_SHA256_Final) | | | |
294 | __weak_alias(SHA256_Transform,_SHA256_Transform) | | | |
295 | | | | |
296 | __weak_alias(SHA384_Init,_SHA384_Init) | | | |
297 | __weak_alias(SHA384_Update,_SHA384_Update) | | | |
298 | __weak_alias(SHA384_Final,_SHA384_Final) | | | |
299 | __weak_alias(SHA384_Transform,_SHA384_Transform) | | | |
300 | | | | |
301 | __weak_alias(SHA512_Init,_SHA512_Init) | | | |
302 | __weak_alias(SHA512_Update,_SHA512_Update) | | | |
303 | __weak_alias(SHA512_Final,_SHA512_Final) | | | |
304 | __weak_alias(SHA512_Transform,_SHA512_Transform) | | | |
305 | #endif | | | |
306 | #endif | | | |
307 | | | | |
308 | /*** SHA-256: *********************************************************/ | | 284 | /*** SHA-256: *********************************************************/ |
309 | int | | 285 | int |
310 | SHA256_Init(SHA256_CTX *context) | | 286 | SHA256_Init(SHA256_CTX *context) |
311 | { | | 287 | { |
312 | if (context == NULL) | | 288 | if (context == NULL) |
313 | return 1; | | 289 | return 1; |
314 | | | 290 | |
315 | memcpy(context->state, sha256_initial_hash_value, | | 291 | memcpy(context->state, sha256_initial_hash_value, |
316 | (size_t)(SHA256_DIGEST_LENGTH)); | | 292 | (size_t)(SHA256_DIGEST_LENGTH)); |
317 | memset(context->buffer, 0, (size_t)(SHA256_BLOCK_LENGTH)); | | 293 | memset(context->buffer, 0, (size_t)(SHA256_BLOCK_LENGTH)); |
318 | context->bitcount = 0; | | 294 | context->bitcount = 0; |
319 | | | 295 | |
320 | return 1; | | 296 | return 1; |