1 #ifndef EL__UTIL_SHA1_H
2 #define EL__UTIL_SHA1_H
4 /* The contents of this file are subject to the Mozilla Public
5 * License Version 1.1 (the "License"); you may not use this file
6 * except in compliance with the License. You may obtain a copy of
7 * the License at http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS
10 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11 * implied. See the License for the specific language governing
12 * rights and limitations under the License.
14 * The Original Code is SHA 180-1 Header File
16 * The Initial Developer of the Original Code is Paul Kocher of
17 * Cryptography Research. Portions created by Paul Kocher are
18 * Copyright (C) 1995-9 by Cryptography Research, Inc. All
25 * Alternatively, the contents of this file may be used under the
26 * terms of the GNU General Public License Version 2 or later (the
27 * "GPL"), in which case the provisions of the GPL are applicable
28 * instead of those above. If you wish to allow use of your
29 * version of this file only under the terms of the GPL and not to
30 * allow others to use your version of this file under the MPL,
31 * indicate your decision by deleting the provisions above and
32 * replace them with the notice and other provisions required by
33 * the GPL. If you do not delete the provisions above, a recipient
34 * may use your version of this file under either the MPL or the
37 /* Optionally SHA1 support can depend on external implementation when linking
38 * against a SSL library that supports it. */
39 #if defined(CONFIG_OWN_LIBC)
41 #elif defined(CONFIG_OPENSSL)
42 #include <openssl/sha.h>
47 #ifndef SHA_DIGEST_LENGTH
48 #define SHA_DIGEST_LENGTH 20
51 #define SHA_HEX_DIGEST_LENGTH (SHA_DIGEST_LENGTH * 2)
53 typedef unsigned char sha1_digest_bin_T
[SHA_DIGEST_LENGTH
];
54 typedef unsigned char sha1_digest_hex_T
[SHA_HEX_DIGEST_LENGTH
];
60 unsigned int sizeHi
,sizeLo
;
63 void init_sha1(struct sha1_context
*context
);
64 void update_sha1(struct sha1_context
*context
, const unsigned char *data
, unsigned long length
);
65 void done_sha1(struct sha1_context
*context
, sha1_digest_bin_T digest
);
68 digest_sha1(const unsigned char *data
, unsigned long length
, sha1_digest_bin_T digest
);
71 /* Provide compatibility with the OpenSSL interface: */
73 typedef struct sha1_context SHA_CTX
;
74 #define SHA1_Init(context) init_sha1(context)
75 #define SHA1_Update(context, data, len) update_sha1(context, data, len)
76 #define SHA1_Final(sha1, context) done_sha1(context, sha1)
77 #define SHA1(data, len, sha1) digest_sha1(data, len, sha1)
79 #endif /* CONFIG_SHA1 */