]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/sha.h
Add CPU info to the speed command summary
[thirdparty/openssl.git] / include / openssl / sha.h
CommitLineData
21dcbebc
RS
1/*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
d02b48c6 3 *
48f4ad77 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
21dcbebc
RS
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
d02b48c6
RE
8 */
9
10#ifndef HEADER_SHA_H
0f113f3e 11# define HEADER_SHA_H
d02b48c6 12
0f113f3e
MC
13# include <openssl/e_os2.h>
14# include <stddef.h>
cf1b7d96 15
d02b48c6
RE
16#ifdef __cplusplus
17extern "C" {
18#endif
19
1d97c843 20/*-
8e7f966b 21 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
04f8bcf1 22 * ! SHA_LONG has to be at least 32 bits wide. !
8e7f966b
UM
23 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24 */
04f8bcf1 25# define SHA_LONG unsigned int
0f113f3e
MC
26
27# define SHA_LBLOCK 16
28# define SHA_CBLOCK (SHA_LBLOCK*4)/* SHA treats input data as a
29 * contiguous array of 32 bit wide
30 * big-endian values. */
31# define SHA_LAST_BLOCK (SHA_CBLOCK-8)
32# define SHA_DIGEST_LENGTH 20
33
34typedef struct SHAstate_st {
35 SHA_LONG h0, h1, h2, h3, h4;
36 SHA_LONG Nl, Nh;
37 SHA_LONG data[SHA_LBLOCK];
38 unsigned int num;
39} SHA_CTX;
40
2dc769a1 41int SHA1_Init(SHA_CTX *c);
9e0aad9f 42int SHA1_Update(SHA_CTX *c, const void *data, size_t len);
2dc769a1 43int SHA1_Final(unsigned char *md, SHA_CTX *c);
9e0aad9f 44unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);
7f7c318c 45void SHA1_Transform(SHA_CTX *c, const unsigned char *data);
0f113f3e
MC
46
47# define SHA256_CBLOCK (SHA_LBLOCK*4)/* SHA-256 treats input data as a
48 * contiguous array of 32 bit wide
49 * big-endian values. */
0f113f3e
MC
50
51typedef struct SHA256state_st {
52 SHA_LONG h[8];
53 SHA_LONG Nl, Nh;
54 SHA_LONG data[SHA_LBLOCK];
55 unsigned int num, md_len;
56} SHA256_CTX;
57
c842261b
AP
58int SHA224_Init(SHA256_CTX *c);
59int SHA224_Update(SHA256_CTX *c, const void *data, size_t len);
60int SHA224_Final(unsigned char *md, SHA256_CTX *c);
0f113f3e 61unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md);
c842261b
AP
62int SHA256_Init(SHA256_CTX *c);
63int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
64int SHA256_Final(unsigned char *md, SHA256_CTX *c);
0f113f3e 65unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md);
c842261b 66void SHA256_Transform(SHA256_CTX *c, const unsigned char *data);
c842261b 67
474e469b
RS
68# define SHA224_DIGEST_LENGTH 28
69# define SHA256_DIGEST_LENGTH 32
0f113f3e
MC
70# define SHA384_DIGEST_LENGTH 48
71# define SHA512_DIGEST_LENGTH 64
c842261b
AP
72
73/*
74 * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64
75 * being exactly 64-bit wide. See Implementation Notes in sha512.c
76 * for further details.
77 */
dbd87ffc
MC
78/*
79 * SHA-512 treats input data as a
80 * contiguous array of 64 bit
81 * wide big-endian values.
82 */
474e469b
RS
83# define SHA512_CBLOCK (SHA_LBLOCK*8)
84# if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
85# define SHA_LONG64 unsigned __int64
86# define U64(C) C##UI64
87# elif defined(__arch64__)
88# define SHA_LONG64 unsigned long
89# define U64(C) C##UL
90# else
91# define SHA_LONG64 unsigned long long
92# define U64(C) C##ULL
93# endif
0f113f3e
MC
94
95typedef struct SHA512state_st {
96 SHA_LONG64 h[8];
97 SHA_LONG64 Nl, Nh;
98 union {
99 SHA_LONG64 d[SHA_LBLOCK];
100 unsigned char p[SHA512_CBLOCK];
101 } u;
102 unsigned int num, md_len;
103} SHA512_CTX;
0f113f3e 104
c842261b
AP
105int SHA384_Init(SHA512_CTX *c);
106int SHA384_Update(SHA512_CTX *c, const void *data, size_t len);
107int SHA384_Final(unsigned char *md, SHA512_CTX *c);
0f113f3e 108unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md);
c842261b
AP
109int SHA512_Init(SHA512_CTX *c);
110int SHA512_Update(SHA512_CTX *c, const void *data, size_t len);
111int SHA512_Final(unsigned char *md, SHA512_CTX *c);
0f113f3e 112unsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md);
c842261b 113void SHA512_Transform(SHA512_CTX *c, const unsigned char *data);
c842261b 114
d02b48c6
RE
115#ifdef __cplusplus
116}
117#endif
118
119#endif