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