diff options
| author | beck <> | 1999-09-29 04:37:45 +0000 |
|---|---|---|
| committer | beck <> | 1999-09-29 04:37:45 +0000 |
| commit | de8f24ea083384bb66b32ec105dc4743c5663cdf (patch) | |
| tree | 1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/hmac | |
| parent | cb929d29896bcb87c2a97417fbd03e50078fc178 (diff) | |
| download | openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2 openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip | |
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/hmac')
| -rw-r--r-- | src/lib/libcrypto/hmac/Makefile.ssl | 44 | ||||
| -rw-r--r-- | src/lib/libcrypto/hmac/hmac.c | 33 | ||||
| -rw-r--r-- | src/lib/libcrypto/hmac/hmac.h | 28 | ||||
| -rw-r--r-- | src/lib/libcrypto/hmac/hmactest.c | 34 |
4 files changed, 72 insertions, 67 deletions
diff --git a/src/lib/libcrypto/hmac/Makefile.ssl b/src/lib/libcrypto/hmac/Makefile.ssl index 7a042b7261..4f5512877e 100644 --- a/src/lib/libcrypto/hmac/Makefile.ssl +++ b/src/lib/libcrypto/hmac/Makefile.ssl | |||
| @@ -7,9 +7,11 @@ TOP= ../.. | |||
| 7 | CC= cc | 7 | CC= cc |
| 8 | INCLUDES= | 8 | INCLUDES= |
| 9 | CFLAG=-g | 9 | CFLAG=-g |
| 10 | INSTALL_PREFIX= | ||
| 11 | OPENSSLDIR= /usr/local/ssl | ||
| 10 | INSTALLTOP=/usr/local/ssl | 12 | INSTALLTOP=/usr/local/ssl |
| 11 | MAKE= make -f Makefile.ssl | 13 | MAKE= make -f Makefile.ssl |
| 12 | MAKEDEPEND= makedepend -f Makefile.ssl | 14 | MAKEDEPEND= $(TOP)/util/domd $(TOP) |
| 13 | MAKEFILE= Makefile.ssl | 15 | MAKEFILE= Makefile.ssl |
| 14 | AR= ar r | 16 | AR= ar r |
| 15 | 17 | ||
| @@ -37,24 +39,23 @@ all: lib | |||
| 37 | 39 | ||
| 38 | lib: $(LIBOBJ) | 40 | lib: $(LIBOBJ) |
| 39 | $(AR) $(LIB) $(LIBOBJ) | 41 | $(AR) $(LIB) $(LIBOBJ) |
| 40 | sh $(TOP)/util/ranlib.sh $(LIB) | 42 | $(RANLIB) $(LIB) |
| 41 | @touch lib | 43 | @touch lib |
| 42 | 44 | ||
| 43 | files: | 45 | files: |
| 44 | perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO | 46 | $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO |
| 45 | 47 | ||
| 46 | links: | 48 | links: |
| 47 | /bin/rm -f Makefile | 49 | @$(TOP)/util/point.sh Makefile.ssl Makefile |
| 48 | $(TOP)/util/point.sh Makefile.ssl Makefile ; | 50 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) |
| 49 | $(TOP)/util/mklink.sh ../../include $(EXHEADER) | 51 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) |
| 50 | $(TOP)/util/mklink.sh ../../test $(TEST) | 52 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) |
| 51 | $(TOP)/util/mklink.sh ../../apps $(APPS) | ||
| 52 | 53 | ||
| 53 | install: | 54 | install: |
| 54 | @for i in $(EXHEADER) ; \ | 55 | @for i in $(EXHEADER) ; \ |
| 55 | do \ | 56 | do \ |
| 56 | (cp $$i $(INSTALLTOP)/include/$$i; \ | 57 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ |
| 57 | chmod 644 $(INSTALLTOP)/include/$$i ); \ | 58 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ |
| 58 | done; | 59 | done; |
| 59 | 60 | ||
| 60 | tags: | 61 | tags: |
| @@ -66,15 +67,28 @@ lint: | |||
| 66 | lint -DLINT $(INCLUDES) $(SRC)>fluff | 67 | lint -DLINT $(INCLUDES) $(SRC)>fluff |
| 67 | 68 | ||
| 68 | depend: | 69 | depend: |
| 69 | $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) | 70 | $(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) |
| 70 | 71 | ||
| 71 | dclean: | 72 | dclean: |
| 72 | perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | 73 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new |
| 73 | mv -f Makefile.new $(MAKEFILE) | 74 | mv -f Makefile.new $(MAKEFILE) |
| 74 | 75 | ||
| 75 | clean: | 76 | clean: |
| 76 | /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | 77 | rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff |
| 77 | |||
| 78 | errors: | ||
| 79 | 78 | ||
| 80 | # DO NOT DELETE THIS LINE -- make depend depends on it. | 79 | # DO NOT DELETE THIS LINE -- make depend depends on it. |
| 80 | |||
| 81 | hmac.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 82 | hmac.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
| 83 | hmac.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | ||
| 84 | hmac.o: ../../include/openssl/des.h ../../include/openssl/dh.h | ||
| 85 | hmac.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 86 | hmac.o: ../../include/openssl/evp.h ../../include/openssl/hmac.h | ||
| 87 | hmac.o: ../../include/openssl/idea.h ../../include/openssl/md2.h | ||
| 88 | hmac.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 89 | hmac.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 90 | hmac.o: ../../include/openssl/opensslv.h ../../include/openssl/rc2.h | ||
| 91 | hmac.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
| 92 | hmac.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
| 93 | hmac.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 94 | hmac.o: ../../include/openssl/stack.h | ||
diff --git a/src/lib/libcrypto/hmac/hmac.c b/src/lib/libcrypto/hmac/hmac.c index fb09129963..5c349bbb56 100644 --- a/src/lib/libcrypto/hmac/hmac.c +++ b/src/lib/libcrypto/hmac/hmac.c | |||
| @@ -58,13 +58,10 @@ | |||
| 58 | #include <stdio.h> | 58 | #include <stdio.h> |
| 59 | #include <stdlib.h> | 59 | #include <stdlib.h> |
| 60 | #include <string.h> | 60 | #include <string.h> |
| 61 | #include "hmac.h" | 61 | #include <openssl/hmac.h> |
| 62 | 62 | ||
| 63 | void HMAC_Init(ctx,key,len,md) | 63 | void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, |
| 64 | HMAC_CTX *ctx; | 64 | const EVP_MD *md) |
| 65 | unsigned char *key; | ||
| 66 | int len; | ||
| 67 | EVP_MD *md; | ||
| 68 | { | 65 | { |
| 69 | int i,j,reset=0; | 66 | int i,j,reset=0; |
| 70 | unsigned char pad[HMAC_MAX_MD_CBLOCK]; | 67 | unsigned char pad[HMAC_MAX_MD_CBLOCK]; |
| @@ -112,18 +109,12 @@ EVP_MD *md; | |||
| 112 | memcpy(&ctx->md_ctx,&ctx->i_ctx,sizeof(ctx->i_ctx)); | 109 | memcpy(&ctx->md_ctx,&ctx->i_ctx,sizeof(ctx->i_ctx)); |
| 113 | } | 110 | } |
| 114 | 111 | ||
| 115 | void HMAC_Update(ctx,data,len) | 112 | void HMAC_Update(HMAC_CTX *ctx, unsigned char *data, int len) |
| 116 | HMAC_CTX *ctx; | ||
| 117 | unsigned char *data; | ||
| 118 | int len; | ||
| 119 | { | 113 | { |
| 120 | EVP_DigestUpdate(&(ctx->md_ctx),data,len); | 114 | EVP_DigestUpdate(&(ctx->md_ctx),data,len); |
| 121 | } | 115 | } |
| 122 | 116 | ||
| 123 | void HMAC_Final(ctx,md,len) | 117 | void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) |
| 124 | HMAC_CTX *ctx; | ||
| 125 | unsigned char *md; | ||
| 126 | unsigned int *len; | ||
| 127 | { | 118 | { |
| 128 | int j; | 119 | int j; |
| 129 | unsigned int i; | 120 | unsigned int i; |
| @@ -137,20 +128,14 @@ unsigned int *len; | |||
| 137 | EVP_DigestFinal(&(ctx->md_ctx),md,len); | 128 | EVP_DigestFinal(&(ctx->md_ctx),md,len); |
| 138 | } | 129 | } |
| 139 | 130 | ||
| 140 | void HMAC_cleanup(ctx) | 131 | void HMAC_cleanup(HMAC_CTX *ctx) |
| 141 | HMAC_CTX *ctx; | ||
| 142 | { | 132 | { |
| 143 | memset(ctx,0,sizeof(HMAC_CTX)); | 133 | memset(ctx,0,sizeof(HMAC_CTX)); |
| 144 | } | 134 | } |
| 145 | 135 | ||
| 146 | unsigned char *HMAC(evp_md,key,key_len,d,n,md,md_len) | 136 | unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, |
| 147 | EVP_MD *evp_md; | 137 | unsigned char *d, int n, unsigned char *md, |
| 148 | unsigned char *key; | 138 | unsigned int *md_len) |
| 149 | int key_len; | ||
| 150 | unsigned char *d; | ||
| 151 | int n; | ||
| 152 | unsigned char *md; | ||
| 153 | unsigned int *md_len; | ||
| 154 | { | 139 | { |
| 155 | HMAC_CTX c; | 140 | HMAC_CTX c; |
| 156 | static unsigned char m[EVP_MAX_MD_SIZE]; | 141 | static unsigned char m[EVP_MAX_MD_SIZE]; |
diff --git a/src/lib/libcrypto/hmac/hmac.h b/src/lib/libcrypto/hmac/hmac.h index e6b43f52c4..f928975fcd 100644 --- a/src/lib/libcrypto/hmac/hmac.h +++ b/src/lib/libcrypto/hmac/hmac.h | |||
| @@ -62,13 +62,17 @@ | |||
| 62 | extern "C" { | 62 | extern "C" { |
| 63 | #endif | 63 | #endif |
| 64 | 64 | ||
| 65 | #include "evp.h" | 65 | #ifdef NO_HMAC |
| 66 | #error HMAC is disabled. | ||
| 67 | #endif | ||
| 68 | |||
| 69 | #include <openssl/evp.h> | ||
| 66 | 70 | ||
| 67 | #define HMAC_MAX_MD_CBLOCK 64 | 71 | #define HMAC_MAX_MD_CBLOCK 64 |
| 68 | 72 | ||
| 69 | typedef struct hmac_ctx_st | 73 | typedef struct hmac_ctx_st |
| 70 | { | 74 | { |
| 71 | EVP_MD *md; | 75 | const EVP_MD *md; |
| 72 | EVP_MD_CTX md_ctx; | 76 | EVP_MD_CTX md_ctx; |
| 73 | EVP_MD_CTX i_ctx; | 77 | EVP_MD_CTX i_ctx; |
| 74 | EVP_MD_CTX o_ctx; | 78 | EVP_MD_CTX o_ctx; |
| @@ -78,26 +82,16 @@ typedef struct hmac_ctx_st | |||
| 78 | 82 | ||
| 79 | #define HMAC_size(e) (EVP_MD_size((e)->md)) | 83 | #define HMAC_size(e) (EVP_MD_size((e)->md)) |
| 80 | 84 | ||
| 81 | #ifndef NOPROTO | ||
| 82 | 85 | ||
| 83 | void HMAC_Init(HMAC_CTX *ctx, unsigned char *key, int len, | 86 | void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, |
| 84 | EVP_MD *md); | 87 | const EVP_MD *md); |
| 85 | void HMAC_Update(HMAC_CTX *ctx,unsigned char *key, int len); | 88 | void HMAC_Update(HMAC_CTX *ctx,unsigned char *key, int len); |
| 86 | void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); | 89 | void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); |
| 87 | void HMAC_cleanup(HMAC_CTX *ctx); | 90 | void HMAC_cleanup(HMAC_CTX *ctx); |
| 88 | unsigned char *HMAC(EVP_MD *evp_md, unsigned char *key, int key_len, | 91 | unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, |
| 89 | unsigned char *d, int n, unsigned char *md, unsigned int *md_len); | 92 | unsigned char *d, int n, unsigned char *md, |
| 90 | 93 | unsigned int *md_len); | |
| 91 | 94 | ||
| 92 | #else | ||
| 93 | |||
| 94 | void HMAC_Init(); | ||
| 95 | void HMAC_Update(); | ||
| 96 | void HMAC_Final(); | ||
| 97 | void HMAC_cleanup(); | ||
| 98 | unsigned char *HMAC(); | ||
| 99 | |||
| 100 | #endif | ||
| 101 | 95 | ||
| 102 | #ifdef __cplusplus | 96 | #ifdef __cplusplus |
| 103 | } | 97 | } |
diff --git a/src/lib/libcrypto/hmac/hmactest.c b/src/lib/libcrypto/hmac/hmactest.c index 5938e375dc..9a67dff36a 100644 --- a/src/lib/libcrypto/hmac/hmactest.c +++ b/src/lib/libcrypto/hmac/hmactest.c | |||
| @@ -59,7 +59,19 @@ | |||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <string.h> | 60 | #include <string.h> |
| 61 | #include <stdlib.h> | 61 | #include <stdlib.h> |
| 62 | #include "hmac.h" | 62 | |
| 63 | #ifdef NO_HMAC | ||
| 64 | int main(int argc, char *argv[]) | ||
| 65 | { | ||
| 66 | printf("No HMAC support\n"); | ||
| 67 | return(0); | ||
| 68 | } | ||
| 69 | #else | ||
| 70 | #include <openssl/hmac.h> | ||
| 71 | |||
| 72 | #ifdef CHARSET_EBCDIC | ||
| 73 | #include <openssl/ebcdic.h> | ||
| 74 | #endif | ||
| 63 | 75 | ||
| 64 | struct test_st | 76 | struct test_st |
| 65 | { | 77 | { |
| @@ -102,19 +114,19 @@ struct test_st | |||
| 102 | }; | 114 | }; |
| 103 | 115 | ||
| 104 | 116 | ||
| 105 | #ifndef NOPROTO | ||
| 106 | static char *pt(unsigned char *md); | 117 | static char *pt(unsigned char *md); |
| 107 | #else | 118 | int main(int argc, char *argv[]) |
| 108 | static char *pt(); | ||
| 109 | #endif | ||
| 110 | |||
| 111 | int main(argc,argv) | ||
| 112 | int argc; | ||
| 113 | char *argv[]; | ||
| 114 | { | 119 | { |
| 115 | int i,err=0; | 120 | int i,err=0; |
| 116 | char *p; | 121 | char *p; |
| 117 | 122 | ||
| 123 | #ifdef CHARSET_EBCDIC | ||
| 124 | ebcdic2ascii(test[0].data, test[0].data, test[0].data_len); | ||
| 125 | ebcdic2ascii(test[1].data, test[1].data, test[1].data_len); | ||
| 126 | ebcdic2ascii(test[2].key, test[2].key, test[2].key_len); | ||
| 127 | ebcdic2ascii(test[2].data, test[2].data, test[2].data_len); | ||
| 128 | #endif | ||
| 129 | |||
| 118 | for (i=0; i<4; i++) | 130 | for (i=0; i<4; i++) |
| 119 | { | 131 | { |
| 120 | p=pt(HMAC(EVP_md5(), | 132 | p=pt(HMAC(EVP_md5(), |
| @@ -135,8 +147,7 @@ char *argv[]; | |||
| 135 | return(0); | 147 | return(0); |
| 136 | } | 148 | } |
| 137 | 149 | ||
| 138 | static char *pt(md) | 150 | static char *pt(unsigned char *md) |
| 139 | unsigned char *md; | ||
| 140 | { | 151 | { |
| 141 | int i; | 152 | int i; |
| 142 | static char buf[80]; | 153 | static char buf[80]; |
| @@ -145,3 +156,4 @@ unsigned char *md; | |||
| 145 | sprintf(&(buf[i*2]),"%02x",md[i]); | 156 | sprintf(&(buf[i*2]),"%02x",md[i]); |
| 146 | return(buf); | 157 | return(buf); |
| 147 | } | 158 | } |
| 159 | #endif | ||
