diff options
| author | Zhanna Tsitkov <tsitkova@mit.edu> | 2009-09-03 18:33:13 +0000 |
|---|---|---|
| committer | Zhanna Tsitkov <tsitkova@mit.edu> | 2009-09-03 18:33:13 +0000 |
| commit | 65cc35ec82d56b8cd89751ddc5f68751271b985c (patch) | |
| tree | d18357e0b500cf7f8c4b93ef4d67fe7485d50257 /src/lib/crypto/openssl/sha1 | |
| parent | 3e76c60f9f08b5f9f78d8e266d0109c85405c06f (diff) | |
| download | krb5-65cc35ec82d56b8cd89751ddc5f68751271b985c.tar.gz krb5-65cc35ec82d56b8cd89751ddc5f68751271b985c.tar.xz krb5-65cc35ec82d56b8cd89751ddc5f68751271b985c.zip | |
Crypto modularity proj: OpemSSL crypto feed for hmac/md5/md4/sha1/rc4/des/des3(w/o iov)
bigredbutton: whitespace
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@22709 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/crypto/openssl/sha1')
| -rw-r--r-- | src/lib/crypto/openssl/sha1/deps | 13 | ||||
| -rw-r--r-- | src/lib/crypto/openssl/sha1/shs.c | 34 | ||||
| -rw-r--r-- | src/lib/crypto/openssl/sha1/shs.h | 49 |
3 files changed, 96 insertions, 0 deletions
diff --git a/src/lib/crypto/openssl/sha1/deps b/src/lib/crypto/openssl/sha1/deps new file mode 100644 index 000000000..a8f51a8e6 --- /dev/null +++ b/src/lib/crypto/openssl/sha1/deps @@ -0,0 +1,13 @@ +# +# Generated makefile dependencies follow. +# +shs.so shs.po $(OUTPRE)shs.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ + $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \ + $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(SRCTOP)/include/autoconf.h \ + $(SRCTOP)/include/k5-buf.h $(SRCTOP)/include/k5-err.h \ + $(SRCTOP)/include/k5-gmt_mktime.h $(SRCTOP)/include/k5-int-pkinit.h \ + $(SRCTOP)/include/k5-int.h $(SRCTOP)/include/k5-platform.h \ + $(SRCTOP)/include/k5-plugin.h $(SRCTOP)/include/k5-thread.h \ + $(SRCTOP)/include/krb5.h $(SRCTOP)/include/krb5/locate_plugin.h \ + $(SRCTOP)/include/krb5/preauth_plugin.h $(SRCTOP)/include/port-sockets.h \ + $(SRCTOP)/include/socket-utils.h shs.c shs.h diff --git a/src/lib/crypto/openssl/sha1/shs.c b/src/lib/crypto/openssl/sha1/shs.c new file mode 100644 index 000000000..9fb60f87c --- /dev/null +++ b/src/lib/crypto/openssl/sha1/shs.c @@ -0,0 +1,34 @@ +#include "shs.h" +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#include <string.h> + +/* Initialize the SHS values */ +void shsInit(SHS_INFO *shsInfo) +{ + EVP_MD_CTX_init(&shsInfo->ossl_sha1_ctx ); + EVP_DigestInit_ex(&shsInfo->ossl_sha1_ctx , EVP_sha1(), NULL); +} + +/* Update SHS for a block of data */ + +void shsUpdate(SHS_INFO *shsInfo, const SHS_BYTE *buffer, unsigned int count) +{ + EVP_DigestUpdate(&shsInfo->ossl_sha1_ctx , buffer, count); +} +/* Final wrapup - pad to SHS_DATASIZE-byte boundary with the bit pattern + 1 0* (64-bit count of bits processed, MSB-first) */ + +void shsFinal(SHS_INFO *shsInfo) +{ + unsigned char *digest_buf = NULL; + + digest_buf = (unsigned char *)OPENSSL_malloc( sizeof(shsInfo->digest)); + + EVP_DigestFinal_ex(&shsInfo->ossl_sha1_ctx , digest_buf , &shsInfo->digest_len); + + memcpy(shsInfo->digest, digest_buf, shsInfo->digest_len); + OPENSSL_free(digest_buf); + EVP_MD_CTX_cleanup(&shsInfo->ossl_sha1_ctx ); +} diff --git a/src/lib/crypto/openssl/sha1/shs.h b/src/lib/crypto/openssl/sha1/shs.h new file mode 100644 index 000000000..66e91b69b --- /dev/null +++ b/src/lib/crypto/openssl/sha1/shs.h @@ -0,0 +1,49 @@ +#ifndef _SHS_DEFINED + +#include "k5-int.h" +#include <openssl/evp.h> +#include <openssl/sha.h> + +#define _SHS_DEFINED + +/* Some useful types */ + +typedef krb5_octet SHS_BYTE; +typedef krb5_ui_4 SHS_LONG; + +/* Define the following to use the updated SHS implementation */ +#define NEW_SHS /**/ + +/* The SHS block size and message digest sizes, in bytes */ + +#define SHS_DATASIZE 64 +#define SHS_DIGESTSIZE 20 + +/* The structure for storing SHS info */ + +typedef struct { + EVP_MD_CTX ossl_sha1_ctx; + unsigned int digest_len; + SHS_LONG digest[ 5 ]; /* Message digest */ + SHS_LONG countLo, countHi; /* 64-bit bit count */ + SHS_LONG data[ 16 ]; /* SHS data buffer */ +} SHS_INFO; + +/* Message digest functions (shs.c) */ +void shsInit(SHS_INFO *shsInfo); +void shsUpdate(SHS_INFO *shsInfo, const SHS_BYTE *buffer, unsigned int count); +void shsFinal(SHS_INFO *shsInfo); + + +/* Keyed Message digest functions (hmac_sha.c) */ +krb5_error_code hmac_sha(krb5_octet *text, + int text_len, + krb5_octet *key, + int key_len, + krb5_octet *digest); + + +#define NIST_SHA_CKSUM_LENGTH SHS_DIGESTSIZE +#define HMAC_SHA_CKSUM_LENGTH SHS_DIGESTSIZE + +#endif /* _SHS_DEFINED */ |
