Loading crypto/dsa/Makefile.ssl +12 −2 Original line number Diff line number Diff line Loading @@ -22,8 +22,8 @@ TEST=dsatest.c APPS= LIB=$(TOP)/libcrypto.a LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c dsa_sign.c $(ERRC).c LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_vrf.o dsa_sign.o $(ERRC).o LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c $(ERRC).c LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o $(ERRC).o SRC= $(LIBSRC) Loading Loading @@ -84,6 +84,16 @@ $(ERRC).c: $(ERR).err # DO NOT DELETE THIS LINE -- make depend depends on it. dsa_asn1.o: ../../include/asn1.h ../../include/asn1_mac.h ../../include/bio.h dsa_asn1.o: ../../include/blowfish.h ../../include/bn.h ../../include/buffer.h dsa_asn1.o: ../../include/cast.h ../../include/des.h ../../include/dh.h dsa_asn1.o: ../../include/e_os.h ../../include/err.h ../../include/evp.h dsa_asn1.o: ../../include/idea.h ../../include/md2.h ../../include/md5.h dsa_asn1.o: ../../include/mdc2.h ../../include/objects.h ../../include/pkcs7.h dsa_asn1.o: ../../include/rc2.h ../../include/rc4.h ../../include/rc5.h dsa_asn1.o: ../../include/ripemd.h ../../include/rsa.h ../../include/sha.h dsa_asn1.o: ../../include/stack.h ../../include/x509.h ../../include/x509_vfy.h dsa_asn1.o: ../cryptlib.h ../crypto.h ../opensslv.h dsa.h dsa_err.o: ../../include/bn.h ../../include/err.h dsa.h dsa_gen.o: ../../include/bio.h ../../include/bn.h ../../include/buffer.h dsa_gen.o: ../../include/e_os.h ../../include/err.h ../../include/rand.h Loading crypto/dsa/dsa.err +5 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,11 @@ #define DSA_F_DSA_SIGN 106 #define DSA_F_DSA_SIGN_SETUP 107 #define DSA_F_DSA_VERIFY 108 #define DSA_F_DSA_SIG_NEW 109 #define DSA_F_D2I_DSA_SIG 110 #define DSA_F_I2D_DSA_SIG 111 #define DSA_F_DSA_DO_SIGN 112 #define DSA_F_DSA_DO_VERIFY 113 /* Reason codes. */ #define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 crypto/dsa/dsa.h +28 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,12 @@ typedef struct dsa_st int references; } DSA; typedef struct DSA_SIG_st { BIGNUM *r; BIGNUM *s; } DSA_SIG; #define DSAparams_dup(x) (DSA *)ASN1_dup((int (*)())i2d_DSAparams, \ (char *(*)())d2i_DSAparams,(char *)(x)) #define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \ Loading @@ -110,6 +116,15 @@ typedef struct dsa_st #ifndef NOPROTO DSA_SIG * DSA_SIG_new(void); void DSA_SIG_free(DSA_SIG *a); int i2d_DSA_SIG(DSA_SIG *a, unsigned char **pp); DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, unsigned char **pp, long length); DSA_SIG * DSA_do_sign(unsigned char *dgst,int dlen,DSA *dsa); int DSA_do_verify(unsigned char *dgst,int dgst_len, DSA_SIG *sig,DSA *dsa); DSA * DSA_new(void); int DSA_size(DSA *); /* next 4 return -1 on error */ Loading Loading @@ -146,6 +161,14 @@ int DSA_is_prime(BIGNUM *q,void (*callback)(),char *cb_arg); #else DSA_SIG * DSA_SIG_new(); void DSA_SIG_free(); int i2d_DSA_SIG(); DSA_SIG * d2i_DSA_SIG(); DSA_SIG * DSA_do_sign(); int DSA_do_verify(); DSA * DSA_new(); int DSA_size(); int DSA_sign_setup(); Loading Loading @@ -189,6 +212,11 @@ int DSA_print_fp(); #define DSA_F_DSA_SIGN 106 #define DSA_F_DSA_SIGN_SETUP 107 #define DSA_F_DSA_VERIFY 108 #define DSA_F_DSA_SIG_NEW 109 #define DSA_F_D2I_DSA_SIG 110 #define DSA_F_I2D_DSA_SIG 111 #define DSA_F_DSA_DO_SIGN 112 #define DSA_F_DSA_DO_VERIFY 113 /* Reason codes. */ #define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 Loading crypto/dsa/dsa_asn1.c 0 → 100644 +102 −0 Original line number Diff line number Diff line /* crypto/dsa/dsa_asn1.c */ #include <stdio.h> #include "cryptlib.h" #include "dsa.h" #include "asn1.h" #include "asn1_mac.h" DSA_SIG *DSA_SIG_new(void) { DSA_SIG *ret; ret = Malloc(sizeof(DSA_SIG)); if (ret == NULL) { DSAerr(DSA_F_DSA_SIG_NEW,ERR_R_MALLOC_FAILURE); return(NULL); } ret->r = NULL; ret->s = NULL; return(ret); } void DSA_SIG_free(r) DSA_SIG *r; { if (r == NULL) return; if (r->r) BN_clear_free(r->r); if (r->s) BN_clear_free(r->s); Free(r); } int i2d_DSA_SIG(v,pp) DSA_SIG *v; unsigned char **pp; { int t=0,len; ASN1_INTEGER rbs,sbs; unsigned char *p; rbs.data=Malloc(BN_num_bits(v->r)/8+1); if (rbs.data == NULL) { DSAerr(DSA_F_I2D_DSA_SIG, ERR_R_MALLOC_FAILURE); return(0); } rbs.type=V_ASN1_INTEGER; rbs.length=BN_bn2bin(v->r,rbs.data); sbs.data=Malloc(BN_num_bits(v->s)/8+1); if (sbs.data == NULL) { Free(rbs.data); DSAerr(DSA_F_I2D_DSA_SIG, ERR_R_MALLOC_FAILURE); return(0); } sbs.type=V_ASN1_INTEGER; sbs.length=BN_bn2bin(v->s,sbs.data); len=i2d_ASN1_INTEGER(&rbs,NULL); len+=i2d_ASN1_INTEGER(&sbs,NULL); if (pp) { p=*pp; ASN1_put_object(&p,1,len,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); i2d_ASN1_INTEGER(&rbs,&p); i2d_ASN1_INTEGER(&sbs,&p); } t=ASN1_object_size(1,len,V_ASN1_SEQUENCE); Free(rbs.data); Free(sbs.data); return(t); } DSA_SIG *d2i_DSA_SIG(a,pp,length) DSA_SIG **a; unsigned char **pp; long length; { int i=ERR_R_NESTED_ASN1_ERROR; ASN1_INTEGER *bs=NULL; M_ASN1_D2I_vars(a,DSA_SIG *,DSA_SIG_new); M_ASN1_D2I_Init(); M_ASN1_D2I_start_sequence(); M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); if ((ret->r=BN_bin2bn(bs->data,bs->length,ret->r)) == NULL) goto err_bn; M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); if ((ret->s=BN_bin2bn(bs->data,bs->length,ret->s)) == NULL) goto err_bn; ASN1_BIT_STRING_free(bs); M_ASN1_D2I_Finish_2(a); err_bn: i=ERR_R_BN_LIB; err: DSAerr(DSA_F_D2I_DSA_SIG,i); if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_SIG_free(ret); if (bs != NULL) ASN1_BIT_STRING_free(bs); return(NULL); } crypto/dsa/dsa_err.c +5 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,11 @@ static ERR_STRING_DATA DSA_str_functs[]= {ERR_PACK(0,DSA_F_DSA_SIGN,0), "DSA_sign"}, {ERR_PACK(0,DSA_F_DSA_SIGN_SETUP,0), "DSA_sign_setup"}, {ERR_PACK(0,DSA_F_DSA_VERIFY,0), "DSA_verify"}, {ERR_PACK(0,DSA_F_DSA_SIG_NEW,0), "DSA_SIG_new"}, {ERR_PACK(0,DSA_F_D2I_DSA_SIG,0), "d2i_DSA_SIG"}, {ERR_PACK(0,DSA_F_I2D_DSA_SIG,0), "i2d_DSA_SIG"}, {ERR_PACK(0,DSA_F_DSA_DO_SIGN,0), "DSA_do_sign"}, {ERR_PACK(0,DSA_F_DSA_DO_VERIFY,0), "DSA_do_verify"}, {0,NULL}, }; Loading Loading
crypto/dsa/Makefile.ssl +12 −2 Original line number Diff line number Diff line Loading @@ -22,8 +22,8 @@ TEST=dsatest.c APPS= LIB=$(TOP)/libcrypto.a LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c dsa_sign.c $(ERRC).c LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_vrf.o dsa_sign.o $(ERRC).o LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c $(ERRC).c LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_asn1.o dsa_vrf.o dsa_sign.o $(ERRC).o SRC= $(LIBSRC) Loading Loading @@ -84,6 +84,16 @@ $(ERRC).c: $(ERR).err # DO NOT DELETE THIS LINE -- make depend depends on it. dsa_asn1.o: ../../include/asn1.h ../../include/asn1_mac.h ../../include/bio.h dsa_asn1.o: ../../include/blowfish.h ../../include/bn.h ../../include/buffer.h dsa_asn1.o: ../../include/cast.h ../../include/des.h ../../include/dh.h dsa_asn1.o: ../../include/e_os.h ../../include/err.h ../../include/evp.h dsa_asn1.o: ../../include/idea.h ../../include/md2.h ../../include/md5.h dsa_asn1.o: ../../include/mdc2.h ../../include/objects.h ../../include/pkcs7.h dsa_asn1.o: ../../include/rc2.h ../../include/rc4.h ../../include/rc5.h dsa_asn1.o: ../../include/ripemd.h ../../include/rsa.h ../../include/sha.h dsa_asn1.o: ../../include/stack.h ../../include/x509.h ../../include/x509_vfy.h dsa_asn1.o: ../cryptlib.h ../crypto.h ../opensslv.h dsa.h dsa_err.o: ../../include/bn.h ../../include/err.h dsa.h dsa_gen.o: ../../include/bio.h ../../include/bn.h ../../include/buffer.h dsa_gen.o: ../../include/e_os.h ../../include/err.h ../../include/rand.h Loading
crypto/dsa/dsa.err +5 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,11 @@ #define DSA_F_DSA_SIGN 106 #define DSA_F_DSA_SIGN_SETUP 107 #define DSA_F_DSA_VERIFY 108 #define DSA_F_DSA_SIG_NEW 109 #define DSA_F_D2I_DSA_SIG 110 #define DSA_F_I2D_DSA_SIG 111 #define DSA_F_DSA_DO_SIGN 112 #define DSA_F_DSA_DO_VERIFY 113 /* Reason codes. */ #define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100
crypto/dsa/dsa.h +28 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,12 @@ typedef struct dsa_st int references; } DSA; typedef struct DSA_SIG_st { BIGNUM *r; BIGNUM *s; } DSA_SIG; #define DSAparams_dup(x) (DSA *)ASN1_dup((int (*)())i2d_DSAparams, \ (char *(*)())d2i_DSAparams,(char *)(x)) #define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \ Loading @@ -110,6 +116,15 @@ typedef struct dsa_st #ifndef NOPROTO DSA_SIG * DSA_SIG_new(void); void DSA_SIG_free(DSA_SIG *a); int i2d_DSA_SIG(DSA_SIG *a, unsigned char **pp); DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, unsigned char **pp, long length); DSA_SIG * DSA_do_sign(unsigned char *dgst,int dlen,DSA *dsa); int DSA_do_verify(unsigned char *dgst,int dgst_len, DSA_SIG *sig,DSA *dsa); DSA * DSA_new(void); int DSA_size(DSA *); /* next 4 return -1 on error */ Loading Loading @@ -146,6 +161,14 @@ int DSA_is_prime(BIGNUM *q,void (*callback)(),char *cb_arg); #else DSA_SIG * DSA_SIG_new(); void DSA_SIG_free(); int i2d_DSA_SIG(); DSA_SIG * d2i_DSA_SIG(); DSA_SIG * DSA_do_sign(); int DSA_do_verify(); DSA * DSA_new(); int DSA_size(); int DSA_sign_setup(); Loading Loading @@ -189,6 +212,11 @@ int DSA_print_fp(); #define DSA_F_DSA_SIGN 106 #define DSA_F_DSA_SIGN_SETUP 107 #define DSA_F_DSA_VERIFY 108 #define DSA_F_DSA_SIG_NEW 109 #define DSA_F_D2I_DSA_SIG 110 #define DSA_F_I2D_DSA_SIG 111 #define DSA_F_DSA_DO_SIGN 112 #define DSA_F_DSA_DO_VERIFY 113 /* Reason codes. */ #define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 Loading
crypto/dsa/dsa_asn1.c 0 → 100644 +102 −0 Original line number Diff line number Diff line /* crypto/dsa/dsa_asn1.c */ #include <stdio.h> #include "cryptlib.h" #include "dsa.h" #include "asn1.h" #include "asn1_mac.h" DSA_SIG *DSA_SIG_new(void) { DSA_SIG *ret; ret = Malloc(sizeof(DSA_SIG)); if (ret == NULL) { DSAerr(DSA_F_DSA_SIG_NEW,ERR_R_MALLOC_FAILURE); return(NULL); } ret->r = NULL; ret->s = NULL; return(ret); } void DSA_SIG_free(r) DSA_SIG *r; { if (r == NULL) return; if (r->r) BN_clear_free(r->r); if (r->s) BN_clear_free(r->s); Free(r); } int i2d_DSA_SIG(v,pp) DSA_SIG *v; unsigned char **pp; { int t=0,len; ASN1_INTEGER rbs,sbs; unsigned char *p; rbs.data=Malloc(BN_num_bits(v->r)/8+1); if (rbs.data == NULL) { DSAerr(DSA_F_I2D_DSA_SIG, ERR_R_MALLOC_FAILURE); return(0); } rbs.type=V_ASN1_INTEGER; rbs.length=BN_bn2bin(v->r,rbs.data); sbs.data=Malloc(BN_num_bits(v->s)/8+1); if (sbs.data == NULL) { Free(rbs.data); DSAerr(DSA_F_I2D_DSA_SIG, ERR_R_MALLOC_FAILURE); return(0); } sbs.type=V_ASN1_INTEGER; sbs.length=BN_bn2bin(v->s,sbs.data); len=i2d_ASN1_INTEGER(&rbs,NULL); len+=i2d_ASN1_INTEGER(&sbs,NULL); if (pp) { p=*pp; ASN1_put_object(&p,1,len,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); i2d_ASN1_INTEGER(&rbs,&p); i2d_ASN1_INTEGER(&sbs,&p); } t=ASN1_object_size(1,len,V_ASN1_SEQUENCE); Free(rbs.data); Free(sbs.data); return(t); } DSA_SIG *d2i_DSA_SIG(a,pp,length) DSA_SIG **a; unsigned char **pp; long length; { int i=ERR_R_NESTED_ASN1_ERROR; ASN1_INTEGER *bs=NULL; M_ASN1_D2I_vars(a,DSA_SIG *,DSA_SIG_new); M_ASN1_D2I_Init(); M_ASN1_D2I_start_sequence(); M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); if ((ret->r=BN_bin2bn(bs->data,bs->length,ret->r)) == NULL) goto err_bn; M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); if ((ret->s=BN_bin2bn(bs->data,bs->length,ret->s)) == NULL) goto err_bn; ASN1_BIT_STRING_free(bs); M_ASN1_D2I_Finish_2(a); err_bn: i=ERR_R_BN_LIB; err: DSAerr(DSA_F_D2I_DSA_SIG,i); if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_SIG_free(ret); if (bs != NULL) ASN1_BIT_STRING_free(bs); return(NULL); }
crypto/dsa/dsa_err.c +5 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,11 @@ static ERR_STRING_DATA DSA_str_functs[]= {ERR_PACK(0,DSA_F_DSA_SIGN,0), "DSA_sign"}, {ERR_PACK(0,DSA_F_DSA_SIGN_SETUP,0), "DSA_sign_setup"}, {ERR_PACK(0,DSA_F_DSA_VERIFY,0), "DSA_verify"}, {ERR_PACK(0,DSA_F_DSA_SIG_NEW,0), "DSA_SIG_new"}, {ERR_PACK(0,DSA_F_D2I_DSA_SIG,0), "d2i_DSA_SIG"}, {ERR_PACK(0,DSA_F_I2D_DSA_SIG,0), "i2d_DSA_SIG"}, {ERR_PACK(0,DSA_F_DSA_DO_SIGN,0), "DSA_do_sign"}, {ERR_PACK(0,DSA_F_DSA_DO_VERIFY,0), "DSA_do_verify"}, {0,NULL}, }; Loading