wolfSSL 3.11.1 for TLS1.3 beta
Fork of wolfSSL by
wolfcrypt/src/hash.c@0:d92f9d21154c, 2015-06-26 (annotated)
- Committer:
- wolfSSL
- Date:
- Fri Jun 26 00:39:20 2015 +0000
- Revision:
- 0:d92f9d21154c
wolfSSL 3.6.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wolfSSL | 0:d92f9d21154c | 1 | /* hash.c |
wolfSSL | 0:d92f9d21154c | 2 | * |
wolfSSL | 0:d92f9d21154c | 3 | * Copyright (C) 2006-2015 wolfSSL Inc. |
wolfSSL | 0:d92f9d21154c | 4 | * |
wolfSSL | 0:d92f9d21154c | 5 | * This file is part of wolfSSL. (formerly known as CyaSSL) |
wolfSSL | 0:d92f9d21154c | 6 | * |
wolfSSL | 0:d92f9d21154c | 7 | * wolfSSL is free software; you can redistribute it and/or modify |
wolfSSL | 0:d92f9d21154c | 8 | * it under the terms of the GNU General Public License as published by |
wolfSSL | 0:d92f9d21154c | 9 | * the Free Software Foundation; either version 2 of the License, or |
wolfSSL | 0:d92f9d21154c | 10 | * (at your option) any later version. |
wolfSSL | 0:d92f9d21154c | 11 | * |
wolfSSL | 0:d92f9d21154c | 12 | * wolfSSL is distributed in the hope that it will be useful, |
wolfSSL | 0:d92f9d21154c | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
wolfSSL | 0:d92f9d21154c | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wolfSSL | 0:d92f9d21154c | 15 | * GNU General Public License for more details. |
wolfSSL | 0:d92f9d21154c | 16 | * |
wolfSSL | 0:d92f9d21154c | 17 | * You should have received a copy of the GNU General Public License |
wolfSSL | 0:d92f9d21154c | 18 | * along with this program; if not, write to the Free Software |
wolfSSL | 0:d92f9d21154c | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
wolfSSL | 0:d92f9d21154c | 20 | */ |
wolfSSL | 0:d92f9d21154c | 21 | |
wolfSSL | 0:d92f9d21154c | 22 | #ifdef HAVE_CONFIG_H |
wolfSSL | 0:d92f9d21154c | 23 | #include <config.h> |
wolfSSL | 0:d92f9d21154c | 24 | #endif |
wolfSSL | 0:d92f9d21154c | 25 | |
wolfSSL | 0:d92f9d21154c | 26 | #include <wolfssl/wolfcrypt/settings.h> |
wolfSSL | 0:d92f9d21154c | 27 | |
wolfSSL | 0:d92f9d21154c | 28 | #if !defined(WOLFSSL_TI_HASH) |
wolfSSL | 0:d92f9d21154c | 29 | |
wolfSSL | 0:d92f9d21154c | 30 | #include <wolfssl/wolfcrypt/hash.h> |
wolfSSL | 0:d92f9d21154c | 31 | |
wolfSSL | 0:d92f9d21154c | 32 | #if !defined(NO_MD5) |
wolfSSL | 0:d92f9d21154c | 33 | void wc_Md5GetHash(Md5* md5, byte* hash) |
wolfSSL | 0:d92f9d21154c | 34 | { |
wolfSSL | 0:d92f9d21154c | 35 | Md5 save = *md5 ; |
wolfSSL | 0:d92f9d21154c | 36 | wc_Md5Final(md5, hash) ; |
wolfSSL | 0:d92f9d21154c | 37 | *md5 = save ; |
wolfSSL | 0:d92f9d21154c | 38 | } |
wolfSSL | 0:d92f9d21154c | 39 | |
wolfSSL | 0:d92f9d21154c | 40 | WOLFSSL_API void wc_Md5RestorePos(Md5* m1, Md5* m2) { |
wolfSSL | 0:d92f9d21154c | 41 | *m1 = *m2 ; |
wolfSSL | 0:d92f9d21154c | 42 | } |
wolfSSL | 0:d92f9d21154c | 43 | #endif |
wolfSSL | 0:d92f9d21154c | 44 | |
wolfSSL | 0:d92f9d21154c | 45 | #if !defined(NO_SHA) |
wolfSSL | 0:d92f9d21154c | 46 | int wc_ShaGetHash(Sha* sha, byte* hash) |
wolfSSL | 0:d92f9d21154c | 47 | { |
wolfSSL | 0:d92f9d21154c | 48 | int ret ; |
wolfSSL | 0:d92f9d21154c | 49 | Sha save = *sha ; |
wolfSSL | 0:d92f9d21154c | 50 | ret = wc_ShaFinal(sha, hash) ; |
wolfSSL | 0:d92f9d21154c | 51 | *sha = save ; |
wolfSSL | 0:d92f9d21154c | 52 | return ret ; |
wolfSSL | 0:d92f9d21154c | 53 | } |
wolfSSL | 0:d92f9d21154c | 54 | |
wolfSSL | 0:d92f9d21154c | 55 | WOLFSSL_API void wc_ShaRestorePos(Sha* s1, Sha* s2) { |
wolfSSL | 0:d92f9d21154c | 56 | *s1 = *s2 ; |
wolfSSL | 0:d92f9d21154c | 57 | } |
wolfSSL | 0:d92f9d21154c | 58 | #endif |
wolfSSL | 0:d92f9d21154c | 59 | |
wolfSSL | 0:d92f9d21154c | 60 | #if !defined(NO_SHA256) |
wolfSSL | 0:d92f9d21154c | 61 | int wc_Sha256GetHash(Sha256* sha256, byte* hash) |
wolfSSL | 0:d92f9d21154c | 62 | { |
wolfSSL | 0:d92f9d21154c | 63 | int ret ; |
wolfSSL | 0:d92f9d21154c | 64 | Sha256 save = *sha256 ; |
wolfSSL | 0:d92f9d21154c | 65 | ret = wc_Sha256Final(sha256, hash) ; |
wolfSSL | 0:d92f9d21154c | 66 | *sha256 = save ; |
wolfSSL | 0:d92f9d21154c | 67 | return ret ; |
wolfSSL | 0:d92f9d21154c | 68 | } |
wolfSSL | 0:d92f9d21154c | 69 | |
wolfSSL | 0:d92f9d21154c | 70 | WOLFSSL_API void wc_Sha256RestorePos(Sha256* s1, Sha256* s2) { |
wolfSSL | 0:d92f9d21154c | 71 | *s1 = *s2 ; |
wolfSSL | 0:d92f9d21154c | 72 | } |
wolfSSL | 0:d92f9d21154c | 73 | #endif |
wolfSSL | 0:d92f9d21154c | 74 | |
wolfSSL | 0:d92f9d21154c | 75 | #endif |
wolfSSL | 0:d92f9d21154c | 76 | |
wolfSSL | 0:d92f9d21154c | 77 |