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. */
40 #if defined(CONFIG_OPENSSL)
41 #include <openssl/sha.h>
45 #ifndef SHA_DIGEST_LENGTH
46 #define SHA_DIGEST_LENGTH 20
49 #define SHA_HEX_DIGEST_LENGTH (SHA_DIGEST_LENGTH * 2)
51 typedef unsigned char sha1_digest_bin_T
[SHA_DIGEST_LENGTH
];
52 typedef unsigned char sha1_digest_hex_T
[SHA_HEX_DIGEST_LENGTH
];
58 unsigned int sizeHi
,sizeLo
;
61 void init_sha1(struct sha1_context
*context
);
62 void update_sha1(struct sha1_context
*context
, const unsigned char *data
, unsigned long length
);
63 void done_sha1(struct sha1_context
*context
, sha1_digest_bin_T digest
);
66 digest_sha1(const unsigned char *data
, unsigned long length
, sha1_digest_bin_T digest
);
69 /* Provide compatibility with the OpenSSL interface: */
71 typedef struct sha1_context SHA_CTX
;
72 #define SHA1_Init(context) init_sha1(context)
73 #define SHA1_Update(context, data, len) update_sha1(context, data, len)
74 #define SHA1_Final(sha1, context) done_sha1(context, sha1)
75 #define SHA1(data, len, sha1) digest_sha1(data, len, sha1)
77 #endif /* CONFIG_SHA1 */