summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/hmac
diff options
context:
space:
mode:
authorbeck <>1999-09-29 04:37:45 +0000
committerbeck <>1999-09-29 04:37:45 +0000
commitde8f24ea083384bb66b32ec105dc4743c5663cdf (patch)
tree1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/hmac
parentcb929d29896bcb87c2a97417fbd03e50078fc178 (diff)
downloadopenbsd-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.ssl44
-rw-r--r--src/lib/libcrypto/hmac/hmac.c33
-rw-r--r--src/lib/libcrypto/hmac/hmac.h28
-rw-r--r--src/lib/libcrypto/hmac/hmactest.c34
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= ../..
7CC= cc 7CC= cc
8INCLUDES= 8INCLUDES=
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
10INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl 14MAKEDEPEND= $(TOP)/util/domd $(TOP)
13MAKEFILE= Makefile.ssl 15MAKEFILE= Makefile.ssl
14AR= ar r 16AR= ar r
15 17
@@ -37,24 +39,23 @@ all: lib
37 39
38lib: $(LIBOBJ) 40lib: $(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
43files: 45files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 46 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45 47
46links: 48links:
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
53install: 54install:
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
60tags: 61tags:
@@ -66,15 +67,28 @@ lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff 67 lint -DLINT $(INCLUDES) $(SRC)>fluff
67 68
68depend: 69depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) 70 $(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC)
70 71
71dclean: 72dclean:
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
75clean: 76clean:
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
78errors:
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
81hmac.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
82hmac.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
83hmac.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
84hmac.o: ../../include/openssl/des.h ../../include/openssl/dh.h
85hmac.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
86hmac.o: ../../include/openssl/evp.h ../../include/openssl/hmac.h
87hmac.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
88hmac.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
89hmac.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
90hmac.o: ../../include/openssl/opensslv.h ../../include/openssl/rc2.h
91hmac.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
92hmac.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
93hmac.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
94hmac.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
63void HMAC_Init(ctx,key,len,md) 63void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
64HMAC_CTX *ctx; 64 const EVP_MD *md)
65unsigned char *key;
66int len;
67EVP_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
115void HMAC_Update(ctx,data,len) 112void HMAC_Update(HMAC_CTX *ctx, unsigned char *data, int len)
116HMAC_CTX *ctx;
117unsigned char *data;
118int len;
119 { 113 {
120 EVP_DigestUpdate(&(ctx->md_ctx),data,len); 114 EVP_DigestUpdate(&(ctx->md_ctx),data,len);
121 } 115 }
122 116
123void HMAC_Final(ctx,md,len) 117void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len)
124HMAC_CTX *ctx;
125unsigned char *md;
126unsigned 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
140void HMAC_cleanup(ctx) 131void HMAC_cleanup(HMAC_CTX *ctx)
141HMAC_CTX *ctx;
142 { 132 {
143 memset(ctx,0,sizeof(HMAC_CTX)); 133 memset(ctx,0,sizeof(HMAC_CTX));
144 } 134 }
145 135
146unsigned char *HMAC(evp_md,key,key_len,d,n,md,md_len) 136unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
147EVP_MD *evp_md; 137 unsigned char *d, int n, unsigned char *md,
148unsigned char *key; 138 unsigned int *md_len)
149int key_len;
150unsigned char *d;
151int n;
152unsigned char *md;
153unsigned 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 @@
62extern "C" { 62extern "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
69typedef struct hmac_ctx_st 73typedef 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
83void HMAC_Init(HMAC_CTX *ctx, unsigned char *key, int len, 86void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
84 EVP_MD *md); 87 const EVP_MD *md);
85void HMAC_Update(HMAC_CTX *ctx,unsigned char *key, int len); 88void HMAC_Update(HMAC_CTX *ctx,unsigned char *key, int len);
86void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); 89void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
87void HMAC_cleanup(HMAC_CTX *ctx); 90void HMAC_cleanup(HMAC_CTX *ctx);
88unsigned char *HMAC(EVP_MD *evp_md, unsigned char *key, int key_len, 91unsigned 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
94void HMAC_Init();
95void HMAC_Update();
96void HMAC_Final();
97void HMAC_cleanup();
98unsigned 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
64int 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
64struct test_st 76struct test_st
65 { 77 {
@@ -102,19 +114,19 @@ struct test_st
102 }; 114 };
103 115
104 116
105#ifndef NOPROTO
106static char *pt(unsigned char *md); 117static char *pt(unsigned char *md);
107#else 118int main(int argc, char *argv[])
108static char *pt();
109#endif
110
111int main(argc,argv)
112int argc;
113char *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
138static char *pt(md) 150static char *pt(unsigned char *md)
139unsigned 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