fork of cyassl-lib
Dependents: TLS_cyassl TLS_cyassl
cyassl/ctaocrypt/sha512.h@4:f377303c41be, 2013-09-16 (annotated)
- Committer:
- feb11
- Date:
- Mon Sep 16 09:53:35 2013 +0000
- Revision:
- 4:f377303c41be
- Parent:
- 0:714293de3836
changed settings
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ashleymills | 0:714293de3836 | 1 | /* sha512.h |
ashleymills | 0:714293de3836 | 2 | * |
ashleymills | 0:714293de3836 | 3 | * Copyright (C) 2006-2013 wolfSSL Inc. |
ashleymills | 0:714293de3836 | 4 | * |
ashleymills | 0:714293de3836 | 5 | * This file is part of CyaSSL. |
ashleymills | 0:714293de3836 | 6 | * |
ashleymills | 0:714293de3836 | 7 | * CyaSSL is free software; you can redistribute it and/or modify |
ashleymills | 0:714293de3836 | 8 | * it under the terms of the GNU General Public License as published by |
ashleymills | 0:714293de3836 | 9 | * the Free Software Foundation; either version 2 of the License, or |
ashleymills | 0:714293de3836 | 10 | * (at your option) any later version. |
ashleymills | 0:714293de3836 | 11 | * |
ashleymills | 0:714293de3836 | 12 | * CyaSSL is distributed in the hope that it will be useful, |
ashleymills | 0:714293de3836 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ashleymills | 0:714293de3836 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ashleymills | 0:714293de3836 | 15 | * GNU General Public License for more details. |
ashleymills | 0:714293de3836 | 16 | * |
ashleymills | 0:714293de3836 | 17 | * You should have received a copy of the GNU General Public License |
ashleymills | 0:714293de3836 | 18 | * along with this program; if not, write to the Free Software |
ashleymills | 0:714293de3836 | 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
ashleymills | 0:714293de3836 | 20 | */ |
ashleymills | 0:714293de3836 | 21 | |
ashleymills | 0:714293de3836 | 22 | |
ashleymills | 0:714293de3836 | 23 | #ifdef CYASSL_SHA512 |
ashleymills | 0:714293de3836 | 24 | |
ashleymills | 0:714293de3836 | 25 | #ifndef CTAO_CRYPT_SHA512_H |
ashleymills | 0:714293de3836 | 26 | #define CTAO_CRYPT_SHA512_H |
ashleymills | 0:714293de3836 | 27 | |
ashleymills | 0:714293de3836 | 28 | #include <cyassl/ctaocrypt/types.h> |
ashleymills | 0:714293de3836 | 29 | |
ashleymills | 0:714293de3836 | 30 | #ifdef __cplusplus |
ashleymills | 0:714293de3836 | 31 | extern "C" { |
ashleymills | 0:714293de3836 | 32 | #endif |
ashleymills | 0:714293de3836 | 33 | |
ashleymills | 0:714293de3836 | 34 | |
ashleymills | 0:714293de3836 | 35 | /* in bytes */ |
ashleymills | 0:714293de3836 | 36 | enum { |
ashleymills | 0:714293de3836 | 37 | SHA512 = 4, /* hash type unique */ |
ashleymills | 0:714293de3836 | 38 | SHA512_BLOCK_SIZE = 128, |
ashleymills | 0:714293de3836 | 39 | SHA512_DIGEST_SIZE = 64, |
ashleymills | 0:714293de3836 | 40 | SHA512_PAD_SIZE = 112 |
ashleymills | 0:714293de3836 | 41 | }; |
ashleymills | 0:714293de3836 | 42 | |
ashleymills | 0:714293de3836 | 43 | |
ashleymills | 0:714293de3836 | 44 | /* Sha512 digest */ |
ashleymills | 0:714293de3836 | 45 | typedef struct Sha512 { |
ashleymills | 0:714293de3836 | 46 | word32 buffLen; /* in bytes */ |
ashleymills | 0:714293de3836 | 47 | word32 loLen; /* length in bytes */ |
ashleymills | 0:714293de3836 | 48 | word32 hiLen; /* length in bytes */ |
ashleymills | 0:714293de3836 | 49 | word64 digest[SHA512_DIGEST_SIZE / sizeof(word64)]; |
ashleymills | 0:714293de3836 | 50 | word64 buffer[SHA512_BLOCK_SIZE / sizeof(word64)]; |
ashleymills | 0:714293de3836 | 51 | } Sha512; |
ashleymills | 0:714293de3836 | 52 | |
ashleymills | 0:714293de3836 | 53 | |
ashleymills | 0:714293de3836 | 54 | CYASSL_API void InitSha512(Sha512*); |
ashleymills | 0:714293de3836 | 55 | CYASSL_API void Sha512Update(Sha512*, const byte*, word32); |
ashleymills | 0:714293de3836 | 56 | CYASSL_API void Sha512Final(Sha512*, byte*); |
ashleymills | 0:714293de3836 | 57 | |
ashleymills | 0:714293de3836 | 58 | |
ashleymills | 0:714293de3836 | 59 | #if defined(CYASSL_SHA384) || defined(HAVE_AESGCM) |
ashleymills | 0:714293de3836 | 60 | |
ashleymills | 0:714293de3836 | 61 | /* in bytes */ |
ashleymills | 0:714293de3836 | 62 | enum { |
ashleymills | 0:714293de3836 | 63 | SHA384 = 5, /* hash type unique */ |
ashleymills | 0:714293de3836 | 64 | SHA384_BLOCK_SIZE = 128, |
ashleymills | 0:714293de3836 | 65 | SHA384_DIGEST_SIZE = 48, |
ashleymills | 0:714293de3836 | 66 | SHA384_PAD_SIZE = 112 |
ashleymills | 0:714293de3836 | 67 | }; |
ashleymills | 0:714293de3836 | 68 | |
ashleymills | 0:714293de3836 | 69 | |
ashleymills | 0:714293de3836 | 70 | /* Sha384 digest */ |
ashleymills | 0:714293de3836 | 71 | typedef struct Sha384 { |
ashleymills | 0:714293de3836 | 72 | word32 buffLen; /* in bytes */ |
ashleymills | 0:714293de3836 | 73 | word32 loLen; /* length in bytes */ |
ashleymills | 0:714293de3836 | 74 | word32 hiLen; /* length in bytes */ |
ashleymills | 0:714293de3836 | 75 | word64 digest[SHA512_DIGEST_SIZE / sizeof(word64)]; /* for transform 512 */ |
ashleymills | 0:714293de3836 | 76 | word64 buffer[SHA384_BLOCK_SIZE / sizeof(word64)]; |
ashleymills | 0:714293de3836 | 77 | } Sha384; |
ashleymills | 0:714293de3836 | 78 | |
ashleymills | 0:714293de3836 | 79 | |
ashleymills | 0:714293de3836 | 80 | CYASSL_API void InitSha384(Sha384*); |
ashleymills | 0:714293de3836 | 81 | CYASSL_API void Sha384Update(Sha384*, const byte*, word32); |
ashleymills | 0:714293de3836 | 82 | CYASSL_API void Sha384Final(Sha384*, byte*); |
ashleymills | 0:714293de3836 | 83 | |
ashleymills | 0:714293de3836 | 84 | #endif /* CYASSL_SHA384 */ |
ashleymills | 0:714293de3836 | 85 | |
ashleymills | 0:714293de3836 | 86 | #ifdef __cplusplus |
ashleymills | 0:714293de3836 | 87 | } /* extern "C" */ |
ashleymills | 0:714293de3836 | 88 | #endif |
ashleymills | 0:714293de3836 | 89 | |
ashleymills | 0:714293de3836 | 90 | #endif /* CTAO_CRYPT_SHA512_H */ |
ashleymills | 0:714293de3836 | 91 | #endif /* CYASSL_SHA512 */ |