Import of old SSLeay release: SSLeay 0.9.1b (unreleased)
This commit is contained in:
@@ -22,7 +22,7 @@ MAKEFILE= Makefile.ssl
|
||||
PEX_LIBS=
|
||||
EX_LIBS=
|
||||
|
||||
CFLAGS= $(INCLUDE) $(CFLAG) -DCFLAGS=" \"$(CC) $(CFLAG)\" "
|
||||
CFLAGS= $(INCLUDE) $(CFLAG) -DCFLAGS=" \"$(CC) $(CFLAG)\" " -DPLATFORM=" \"$(PLATFORM)\" "
|
||||
|
||||
ERR=crypto
|
||||
ERRC=cpt_err
|
||||
@@ -34,17 +34,17 @@ SDIRS= md2 md5 sha mdc2 hmac ripemd \
|
||||
bn rsa dsa dh \
|
||||
buffer bio stack lhash rand err objects \
|
||||
evp pem x509 \
|
||||
asn1 conf txt_db pkcs7
|
||||
asn1 conf txt_db pkcs7 comp
|
||||
|
||||
GENERAL=Makefile README
|
||||
|
||||
LIB= $(TOP)/libcrypto.a
|
||||
LIBSRC= cryptlib.c mem.c cversion.c ex_data.c $(ERRC).c
|
||||
LIBOBJ= cryptlib.o mem.o cversion.o ex_data.o $(ERRC).o
|
||||
LIBSRC= cryptlib.c mem.c cversion.c ex_data.c tmdiff.c $(ERRC).c
|
||||
LIBOBJ= cryptlib.o mem.o cversion.o ex_data.o tmdiff.o $(ERRC).o
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
EXHEADER= crypto.h cryptall.h
|
||||
EXHEADER= crypto.h cryptall.h tmdiff.h
|
||||
HEADER= cryptlib.h date.h $(EXHEADER)
|
||||
|
||||
ALL= $(GENERAL) $(SRC) $(HEADER)
|
||||
@@ -61,7 +61,7 @@ subdirs:
|
||||
@for i in $(SDIRS) ;\
|
||||
do \
|
||||
(cd $$i; echo "making all in $$i..."; \
|
||||
$(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_MULW='${BN_MULW}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' all ); \
|
||||
$(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' all ); \
|
||||
done;
|
||||
|
||||
files:
|
||||
|
@@ -23,7 +23,7 @@ APPS=
|
||||
|
||||
LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC= a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c \
|
||||
a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c \
|
||||
a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_bmp.c \
|
||||
a_sign.c a_digest.c a_verify.c \
|
||||
x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c \
|
||||
x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c \
|
||||
@@ -38,7 +38,7 @@ LIBSRC= a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c \
|
||||
asn1_par.c asn1_lib.c $(ERRC).c a_meth.c a_bytes.c \
|
||||
evp_asn1.c
|
||||
LIBOBJ= a_object.o a_bitstr.o a_utctm.o a_int.o a_octet.o a_print.o \
|
||||
a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o \
|
||||
a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o a_bmp.o \
|
||||
a_sign.o a_digest.o a_verify.o \
|
||||
x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o \
|
||||
x_name.o x_cinf.o x_x509.o x_crl.o x_info.o x_spki.o \
|
||||
|
@@ -68,27 +68,50 @@ int i2d_ASN1_BIT_STRING(a,pp)
|
||||
ASN1_BIT_STRING *a;
|
||||
unsigned char **pp;
|
||||
{
|
||||
int ret,j,r,bits;
|
||||
int ret,j,r,bits,len;
|
||||
unsigned char *p,*d;
|
||||
|
||||
if (a == NULL) return(0);
|
||||
|
||||
/* our bit strings are always a multiple of 8 :-) */
|
||||
bits=0;
|
||||
ret=1+a->length;
|
||||
len=a->length;
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
if (a->flags & ASN1_STRING_FLAG_BITS_LEFT)
|
||||
{
|
||||
bits=(int)a->flags&0x07;
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( ; len > 0; len--)
|
||||
{
|
||||
if (a->data[len-1]) break;
|
||||
}
|
||||
j=a->data[len-1];
|
||||
if (j & 0x01) bits=0;
|
||||
else if (j & 0x02) bits=1;
|
||||
else if (j & 0x04) bits=2;
|
||||
else if (j & 0x08) bits=3;
|
||||
else if (j & 0x10) bits=4;
|
||||
else if (j & 0x20) bits=5;
|
||||
else if (j & 0x40) bits=6;
|
||||
else if (j & 0x80) bits=7;
|
||||
else bits=0; /* should not happen */
|
||||
}
|
||||
}
|
||||
else
|
||||
bits=0;
|
||||
ret=1+len;
|
||||
r=ASN1_object_size(0,ret,V_ASN1_BIT_STRING);
|
||||
if (pp == NULL) return(r);
|
||||
p= *pp;
|
||||
|
||||
ASN1_put_object(&p,0,ret,V_ASN1_BIT_STRING,V_ASN1_UNIVERSAL);
|
||||
if (bits == 0)
|
||||
j=0;
|
||||
else j=8-bits;
|
||||
*(p++)=(unsigned char)j;
|
||||
*(p++)=(unsigned char)bits;
|
||||
d=a->data;
|
||||
memcpy(p,d,a->length);
|
||||
p+=a->length;
|
||||
if (a->length > 0) p[-1]&=(0xff<<j);
|
||||
memcpy(p,d,len);
|
||||
p+=len;
|
||||
if (len > 0) p[-1]&=(0xff<<bits);
|
||||
*pp=p;
|
||||
return(r);
|
||||
}
|
||||
@@ -127,6 +150,12 @@ long length;
|
||||
if (len < 1) { i=ASN1_R_STRING_TOO_SHORT; goto err; }
|
||||
|
||||
i= *(p++);
|
||||
/* We do this to preserve the settings. If we modify
|
||||
* the settings, via the _set_bit function, we will recalculate
|
||||
* on output */
|
||||
ret->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear */
|
||||
ret->flags|=(ASN1_STRING_FLAG_BITS_LEFT|(i&0x07)); /* set */
|
||||
|
||||
if (len-- > 1) /* using one because of the bits left byte */
|
||||
{
|
||||
s=(unsigned char *)Malloc((int)len);
|
||||
@@ -170,6 +199,8 @@ int value;
|
||||
v=1<<(7-(n&0x07));
|
||||
iv= ~v;
|
||||
|
||||
a->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear, set on write */
|
||||
|
||||
if (a == NULL) return(0);
|
||||
if ((a->length < (w+1)) || (a->data == NULL))
|
||||
{
|
||||
|
236
crypto/asn1/a_bitstr.orig.c
Normal file
236
crypto/asn1/a_bitstr.orig.c
Normal file
@@ -0,0 +1,236 @@
|
||||
/* crypto/asn1/a_bitstr.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "asn1.h"
|
||||
|
||||
/* ASN1err(ASN1_F_ASN1_STRING_NEW,ASN1_R_STRING_TOO_SHORT);
|
||||
* ASN1err(ASN1_F_D2I_ASN1_BIT_STRING,ASN1_R_EXPECTING_A_BIT_STRING);
|
||||
*/
|
||||
|
||||
int i2d_ASN1_BIT_STRING(a,pp)
|
||||
ASN1_BIT_STRING *a;
|
||||
unsigned char **pp;
|
||||
{
|
||||
int ret,i,j,r,bits,len;
|
||||
unsigned char *p,*d;
|
||||
|
||||
if (a == NULL) return(0);
|
||||
|
||||
len=a->length;
|
||||
|
||||
if ((len > 0)
|
||||
{
|
||||
if (a->flags & ASN1_FG_BITS_LEFT))
|
||||
{
|
||||
bits=a->flags&0x07;
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( ; len > 0; len--)
|
||||
{
|
||||
if (a->data[len-1]) break;
|
||||
}
|
||||
j=a->data[len-1];
|
||||
if (j & 0x80) bits=1;
|
||||
else if (j & 0x40) bits=2;
|
||||
else if (j & 0x20) bits=3;
|
||||
else if (j & 0x10) bits=4;
|
||||
else if (j & 0x08) bits=5;
|
||||
else if (j & 0x04) bits=6;
|
||||
else if (j & 0x02) bits=7;
|
||||
else if (j & 0x01) bits=8;
|
||||
else bits=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
bits=0;
|
||||
ret=1+len;
|
||||
r=ASN1_object_size(0,ret,V_ASN1_BIT_STRING);
|
||||
if (pp == NULL) return(r);
|
||||
p= *pp;
|
||||
|
||||
ASN1_put_object(&p,0,ret,V_ASN1_BIT_STRING,V_ASN1_UNIVERSAL);
|
||||
if (bits == 0)
|
||||
j=0;
|
||||
else j=8-bits;
|
||||
*(p++)=(unsigned char)j;
|
||||
d=a->data;
|
||||
memcpy(p,d,len);
|
||||
p+=len;
|
||||
if (len > 0) p[-1]&=(0xff<<j);
|
||||
*pp=p;
|
||||
return(r);
|
||||
}
|
||||
|
||||
ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(a, pp, length)
|
||||
ASN1_BIT_STRING **a;
|
||||
unsigned char **pp;
|
||||
long length;
|
||||
{
|
||||
ASN1_BIT_STRING *ret=NULL;
|
||||
unsigned char *p,*s;
|
||||
long len;
|
||||
int inf,tag,xclass;
|
||||
int i;
|
||||
|
||||
if ((a == NULL) || ((*a) == NULL))
|
||||
{
|
||||
if ((ret=ASN1_BIT_STRING_new()) == NULL) return(NULL);
|
||||
}
|
||||
else
|
||||
ret=(*a);
|
||||
|
||||
p= *pp;
|
||||
inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
|
||||
if (inf & 0x80)
|
||||
{
|
||||
i=ASN1_R_BAD_OBJECT_HEADER;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (tag != V_ASN1_BIT_STRING)
|
||||
{
|
||||
i=ASN1_R_EXPECTING_A_BIT_STRING;
|
||||
goto err;
|
||||
}
|
||||
if (len < 1) { i=ASN1_R_STRING_TOO_SHORT; goto err; }
|
||||
|
||||
i= *(p++);
|
||||
ret->flag&= ~(ASN1_FG_BITS_LEFT|0x07); /* clear */
|
||||
if (i > 0)
|
||||
ret->flag|=(ASN1_FG_BITS_LEFT|(i&0x07)); /* set */
|
||||
|
||||
if (len-- > 1) /* using one because of the bits left byte */
|
||||
{
|
||||
s=(unsigned char *)Malloc((int)len);
|
||||
if (s == NULL)
|
||||
{
|
||||
i=ERR_R_MALLOC_FAILURE;
|
||||
goto err;
|
||||
}
|
||||
memcpy(s,p,(int)len);
|
||||
s[len-1]&=(0xff<<i);
|
||||
p+=len;
|
||||
}
|
||||
else
|
||||
s=NULL;
|
||||
|
||||
ret->length=(int)len;
|
||||
if (ret->data != NULL) Free((char *)ret->data);
|
||||
ret->data=s;
|
||||
ret->type=V_ASN1_BIT_STRING;
|
||||
if (a != NULL) (*a)=ret;
|
||||
*pp=p;
|
||||
return(ret);
|
||||
err:
|
||||
ASN1err(ASN1_F_D2I_ASN1_BIT_STRING,i);
|
||||
if ((ret != NULL) && ((a == NULL) || (*a != ret)))
|
||||
ASN1_BIT_STRING_free(ret);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* These next 2 functions from Goetz Babin-Ebell <babinebell@trustcenter.de>
|
||||
*/
|
||||
int ASN1_BIT_STRING_set_bit(a,n,value)
|
||||
ASN1_BIT_STRING *a;
|
||||
int n;
|
||||
int value;
|
||||
{
|
||||
int w,v,iv;
|
||||
unsigned char *c;
|
||||
|
||||
w=n/8;
|
||||
v=1<<(7-(n&0x07));
|
||||
iv= ~v;
|
||||
|
||||
a->flag&= ~(ASN1_FG_BITS_LEFT|0x07); /* clear, set on write */
|
||||
|
||||
if (a == NULL) return(0);
|
||||
if ((a->length < (w+1)) || (a->data == NULL))
|
||||
{
|
||||
if (!value) return(1); /* Don't need to set */
|
||||
if (a->data == NULL)
|
||||
c=(unsigned char *)Malloc(w+1);
|
||||
else
|
||||
c=(unsigned char *)Realloc(a->data,w+1);
|
||||
if (c == NULL) return(0);
|
||||
a->data=c;
|
||||
a->length=w+1;
|
||||
c[w]=0;
|
||||
}
|
||||
a->data[w]=((a->data[w])&iv)|v;
|
||||
while ((a->length > 0) && (a->data[a->length-1] == 0))
|
||||
a->length--;
|
||||
return(1);
|
||||
}
|
||||
|
||||
int ASN1_BIT_STRING_get_bit(a,n)
|
||||
ASN1_BIT_STRING *a;
|
||||
int n;
|
||||
{
|
||||
int w,v;
|
||||
|
||||
w=n/8;
|
||||
v=1<<(7-(n&0x07));
|
||||
if ((a == NULL) || (a->length < (w+1)) || (a->data == NULL))
|
||||
return(0);
|
||||
return((a->data[w]&v) != 0);
|
||||
}
|
||||
|
@@ -79,10 +79,10 @@ long length;
|
||||
ASN1_BMPSTRING *ret=NULL;
|
||||
|
||||
ret=(ASN1_BMPSTRING *)d2i_ASN1_bytes((ASN1_STRING **)a,
|
||||
pp,length,V_ASN1_BMPSTRING,V_ASN1_UNIVERSAL);
|
||||
pp,length,V_ASN1_BMPSTRING,V_ASN1_UNIVERSAL);
|
||||
if (ret == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_D2I_ASN1_BMPSTRING,ASN1_R_ERROR_STACK);
|
||||
ASN1err(ASN1_F_D2I_ASN1_BMPSTRING,ERR_R_NESTED_ASN1_ERROR);
|
||||
return(NULL);
|
||||
}
|
||||
return(ret);
|
||||
|
@@ -60,9 +60,7 @@
|
||||
#include "cryptlib.h"
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/* ASN1err(ASN1_F_ASN1_TYPE_NEW,ASN1_R_ERROR_STACK);
|
||||
* ASN1err(ASN1_F_D2I_ASN1_TYPE_BYTES,ASN1_R_ERROR_STACK);
|
||||
* ASN1err(ASN1_F_D2I_ASN1_TYPE_BYTES,ASN1_R_WRONG_TYPE);
|
||||
/* ASN1err(ASN1_F_D2I_ASN1_TYPE_BYTES,ASN1_R_WRONG_TYPE);
|
||||
* ASN1err(ASN1_F_ASN1_COLLATE_PRIMATIVE,ASN1_R_WRONG_TAG);
|
||||
*/
|
||||
|
||||
|
@@ -62,10 +62,10 @@
|
||||
#include "asn1.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_ASN1_HEADER,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_I2D_ASN1_HEADER,ASN1_R_BAD_GET_OBJECT);
|
||||
* ASN1err(ASN1_F_I2D_ASN1_HEADER,ASN1_R_BAD_GET_OBJECT);
|
||||
* ASN1err(ASN1_F_ASN1_HEADER_NEW,ASN1_R_BAD_GET_OBJECT);
|
||||
* ASN1err(ASN1_F_D2I_ASN1_HEADER,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_I2D_ASN1_HEADER,ERR_R_BAD_GET_ASN1_OBJECT_CALL);
|
||||
* ASN1err(ASN1_F_I2D_ASN1_HEADER,ERR_R_BAD_GET_ASN1_OBJECT_CALL);
|
||||
* ASN1err(ASN1_F_ASN1_HEADER_NEW,ERR_R_BAD_GET_ASN1_OBJECT_CALL);
|
||||
*/
|
||||
|
||||
int i2d_ASN1_HEADER(a,pp)
|
||||
@@ -110,6 +110,7 @@ long length;
|
||||
ASN1_HEADER *ASN1_HEADER_new()
|
||||
{
|
||||
ASN1_HEADER *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,ASN1_HEADER);
|
||||
M_ASN1_New(ret->header,ASN1_OCTET_STRING_new);
|
||||
|
@@ -279,7 +279,7 @@ ASN1_INTEGER *ai;
|
||||
ret=ai;
|
||||
if (ret == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ASN1_R_ERROR_STACK);
|
||||
ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_NESTED_ASN1_ERROR);
|
||||
goto err;
|
||||
}
|
||||
ret->type=V_ASN1_INTEGER;
|
||||
|
@@ -382,8 +382,8 @@ char *sn,*ln;
|
||||
o.data=data;
|
||||
o.nid=nid;
|
||||
o.length=len;
|
||||
o.flags=ASN1_OBJECT_FLAG_DYNAMIC|
|
||||
ASN1_OBJECT_FLAG_DYNAMIC_STRINGS|ASN1_OBJECT_FLAG_DYNAMIC_DATA;
|
||||
o.flags=ASN1_OBJECT_FLAG_DYNAMIC|ASN1_OBJECT_FLAG_DYNAMIC_STRINGS|
|
||||
ASN1_OBJECT_FLAG_DYNAMIC_DATA;
|
||||
return(OBJ_dup(&o));
|
||||
}
|
||||
|
||||
|
@@ -82,7 +82,7 @@ long length;
|
||||
pp,length,V_ASN1_OCTET_STRING,V_ASN1_UNIVERSAL);
|
||||
if (ret == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_D2I_ASN1_OCTET_STRING,ASN1_R_ERROR_STACK);
|
||||
ASN1err(ASN1_F_D2I_ASN1_OCTET_STRING,ERR_R_NESTED_ASN1_ERROR);
|
||||
return(NULL);
|
||||
}
|
||||
return(ret);
|
||||
|
@@ -89,11 +89,12 @@ int ex_class;
|
||||
return(r);
|
||||
}
|
||||
|
||||
STACK *d2i_ASN1_SET(a,pp,length,func,ex_tag,ex_class)
|
||||
STACK *d2i_ASN1_SET(a,pp,length,func,free_func,ex_tag,ex_class)
|
||||
STACK **a;
|
||||
unsigned char **pp;
|
||||
long length;
|
||||
char *(*func)();
|
||||
void (*free_func)();
|
||||
int ex_tag;
|
||||
int ex_class;
|
||||
{
|
||||
@@ -136,14 +137,25 @@ int ex_class;
|
||||
char *s;
|
||||
|
||||
if (M_ASN1_D2I_end_sequence()) break;
|
||||
if ((s=func(NULL,&c.p,c.slen,c.max-c.p)) == NULL) goto err;
|
||||
if ((s=func(NULL,&c.p,c.slen,c.max-c.p)) == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_D2I_ASN1_SET,ASN1_R_ERROR_PARSING_SET_ELEMENT);
|
||||
asn1_add_error(*pp,(int)(c.q- *pp));
|
||||
goto err;
|
||||
}
|
||||
if (!sk_push(ret,s)) goto err;
|
||||
}
|
||||
if (a != NULL) (*a)=ret;
|
||||
*pp=c.p;
|
||||
return(ret);
|
||||
err:
|
||||
if ((ret != NULL) && ((a == NULL) || (*a != ret))) sk_free(ret);
|
||||
if ((ret != NULL) && ((a == NULL) || (*a != ret)))
|
||||
{
|
||||
if (free_func != NULL)
|
||||
sk_pop_free(ret,free_func);
|
||||
else
|
||||
sk_free(ret);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@@ -136,7 +136,11 @@ EVP_MD *type;
|
||||
signature->data=buf_out;
|
||||
buf_out=NULL;
|
||||
signature->length=outl;
|
||||
|
||||
/* In the interests of compatability, I'll make sure that
|
||||
* the bit string has a 'not-used bits' value of 0
|
||||
*/
|
||||
signature->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);
|
||||
signature->flags|=ASN1_STRING_FLAG_BITS_LEFT;
|
||||
err:
|
||||
memset(&ctx,0,sizeof(ctx));
|
||||
if (buf_in != NULL)
|
||||
|
@@ -60,9 +60,7 @@
|
||||
#include "cryptlib.h"
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/* ASN1err(ASN1_F_ASN1_TYPE_NEW,ASN1_R_ERROR_STACK);
|
||||
* ASN1err(ASN1_F_D2I_ASN1_BYTES,ASN1_R_ERROR_STACK);
|
||||
* ASN1err(ASN1_F_D2I_ASN1_BYTES,ASN1_R_WRONG_TAG);
|
||||
/* ASN1err(ASN1_F_D2I_ASN1_BYTES,ASN1_R_WRONG_TAG);
|
||||
* ASN1err(ASN1_F_ASN1_COLLATE_PRIMATIVE,ASN1_R_WRONG_TAG);
|
||||
*/
|
||||
|
||||
@@ -252,6 +250,7 @@ err:
|
||||
ASN1_TYPE *ASN1_TYPE_new()
|
||||
{
|
||||
ASN1_TYPE *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,ASN1_TYPE);
|
||||
ret->type= -1;
|
||||
@@ -304,14 +303,20 @@ ASN1_TYPE *a;
|
||||
case V_ASN1_NEG_INTEGER:
|
||||
case V_ASN1_BIT_STRING:
|
||||
case V_ASN1_OCTET_STRING:
|
||||
case V_ASN1_SEQUENCE:
|
||||
case V_ASN1_SET:
|
||||
case V_ASN1_NUMERICSTRING:
|
||||
case V_ASN1_PRINTABLESTRING:
|
||||
case V_ASN1_T61STRING:
|
||||
case V_ASN1_VIDEOTEXSTRING:
|
||||
case V_ASN1_IA5STRING:
|
||||
case V_ASN1_UNIVERSALSTRING:
|
||||
case V_ASN1_GENERALSTRING:
|
||||
case V_ASN1_UTCTIME:
|
||||
case V_ASN1_SET:
|
||||
case V_ASN1_SEQUENCE:
|
||||
case V_ASN1_GENERALIZEDTIME:
|
||||
case V_ASN1_GRAPHICSTRING:
|
||||
case V_ASN1_VISIBLESTRING:
|
||||
case V_ASN1_GENERALSTRING:
|
||||
case V_ASN1_UNIVERSALSTRING:
|
||||
case V_ASN1_BMPSTRING:
|
||||
ASN1_STRING_free((ASN1_STRING *)a->value.ptr);
|
||||
break;
|
||||
default:
|
||||
|
@@ -85,7 +85,7 @@ long length;
|
||||
V_ASN1_UTCTIME,V_ASN1_UNIVERSAL);
|
||||
if (ret == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_D2I_ASN1_UTCTIME,ASN1_R_ERROR_STACK);
|
||||
ASN1err(ASN1_F_D2I_ASN1_UTCTIME,ERR_R_NESTED_ASN1_ERROR);
|
||||
return(NULL);
|
||||
}
|
||||
if (!ASN1_UTCTIME_check(ret))
|
||||
@@ -180,7 +180,7 @@ time_t t;
|
||||
{
|
||||
char *p;
|
||||
struct tm *ts;
|
||||
#if defined(THREADS)
|
||||
#if defined(THREADS) && !defined(WIN32)
|
||||
struct tm data;
|
||||
#endif
|
||||
|
||||
@@ -189,7 +189,7 @@ time_t t;
|
||||
if (s == NULL)
|
||||
return(NULL);
|
||||
|
||||
#if defined(THREADS)
|
||||
#if defined(THREADS) && !defined(WIN32)
|
||||
ts=(struct tm *)gmtime_r(&t,&data);
|
||||
#else
|
||||
ts=(struct tm *)gmtime(&t);
|
||||
|
@@ -126,57 +126,53 @@
|
||||
|
||||
/* Reason codes. */
|
||||
#define ASN1_R_BAD_CLASS 100
|
||||
#define ASN1_R_BAD_GET_OBJECT 101
|
||||
#define ASN1_R_BAD_OBJECT_HEADER 102
|
||||
#define ASN1_R_BAD_PASSWORD_READ 103
|
||||
#define ASN1_R_BAD_PKCS7_CONTENT 104
|
||||
#define ASN1_R_BAD_PKCS7_TYPE 105
|
||||
#define ASN1_R_BAD_TAG 106
|
||||
#define ASN1_R_BAD_TYPE 107
|
||||
#define ASN1_R_BN_LIB 108
|
||||
#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 109
|
||||
#define ASN1_R_BUFFER_TOO_SMALL 110
|
||||
#define ASN1_R_DATA_IS_WRONG 111
|
||||
#define ASN1_R_DECODING_ERROR 112
|
||||
#define ASN1_R_ERROR_STACK 113
|
||||
#define ASN1_R_EXPECTING_AN_INTEGER 114
|
||||
#define ASN1_R_EXPECTING_AN_OBJECT 115
|
||||
#define ASN1_R_EXPECTING_AN_OCTET_STRING 116
|
||||
#define ASN1_R_EXPECTING_A_BIT_STRING 117
|
||||
#define ASN1_R_EXPECTING_A_BOOLEAN 118
|
||||
#define ASN1_R_EXPECTING_A_SEQUENCE 119
|
||||
#define ASN1_R_EXPECTING_A_UTCTIME 120
|
||||
#define ASN1_R_FIRST_NUM_TOO_LARGE 121
|
||||
#define ASN1_R_HEADER_TOO_LONG 122
|
||||
#define ASN1_R_INVALID_DIGIT 123
|
||||
#define ASN1_R_INVALID_SEPARATOR 124
|
||||
#define ASN1_R_INVALID_TIME_FORMAT 125
|
||||
#define ASN1_R_IV_TOO_LARGE 126
|
||||
#define ASN1_R_LENGTH_ERROR 127
|
||||
#define ASN1_R_LENGTH_MISMATCH 128
|
||||
#define ASN1_R_MISSING_EOS 129
|
||||
#define ASN1_R_MISSING_SECOND_NUMBER 130
|
||||
#define ASN1_R_NON_HEX_CHARACTERS 131
|
||||
#define ASN1_R_NOT_ENOUGH_DATA 132
|
||||
#define ASN1_R_ODD_NUMBER_OF_CHARS 133
|
||||
#define ASN1_R_PARSING 134
|
||||
#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 135
|
||||
#define ASN1_R_SECOND_NUMBER_TOO_LARGE 136
|
||||
#define ASN1_R_SHORT_LINE 137
|
||||
#define ASN1_R_STRING_TOO_SHORT 138
|
||||
#define ASN1_R_TAG_VALUE_TOO_HIGH 139
|
||||
#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 140
|
||||
#define ASN1_R_TOO_LONG 141
|
||||
#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 142
|
||||
#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 143
|
||||
#define ASN1_R_UNKNOWN_ATTRIBUTE_TYPE 144
|
||||
#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 145
|
||||
#define ASN1_R_UNKNOWN_OBJECT_TYPE 146
|
||||
#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 147
|
||||
#define ASN1_R_UNSUPPORTED_CIPHER 148
|
||||
#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 149
|
||||
#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 150
|
||||
#define ASN1_R_UTCTIME_TOO_LONG 151
|
||||
#define ASN1_R_WRONG_PRINTABLE_TYPE 152
|
||||
#define ASN1_R_WRONG_TAG 153
|
||||
#define ASN1_R_WRONG_TYPE 154
|
||||
#define ASN1_R_BAD_OBJECT_HEADER 101
|
||||
#define ASN1_R_BAD_PASSWORD_READ 102
|
||||
#define ASN1_R_BAD_PKCS7_CONTENT 103
|
||||
#define ASN1_R_BAD_PKCS7_TYPE 104
|
||||
#define ASN1_R_BAD_TAG 105
|
||||
#define ASN1_R_BAD_TYPE 106
|
||||
#define ASN1_R_BN_LIB 107
|
||||
#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 108
|
||||
#define ASN1_R_BUFFER_TOO_SMALL 109
|
||||
#define ASN1_R_DATA_IS_WRONG 110
|
||||
#define ASN1_R_DECODING_ERROR 111
|
||||
#define ASN1_R_ERROR_PARSING_SET_ELEMENT 112
|
||||
#define ASN1_R_EXPECTING_AN_INTEGER 113
|
||||
#define ASN1_R_EXPECTING_AN_OBJECT 114
|
||||
#define ASN1_R_EXPECTING_AN_OCTET_STRING 115
|
||||
#define ASN1_R_EXPECTING_A_BIT_STRING 116
|
||||
#define ASN1_R_EXPECTING_A_BOOLEAN 117
|
||||
#define ASN1_R_EXPECTING_A_UTCTIME 118
|
||||
#define ASN1_R_FIRST_NUM_TOO_LARGE 119
|
||||
#define ASN1_R_HEADER_TOO_LONG 120
|
||||
#define ASN1_R_INVALID_DIGIT 121
|
||||
#define ASN1_R_INVALID_SEPARATOR 122
|
||||
#define ASN1_R_INVALID_TIME_FORMAT 123
|
||||
#define ASN1_R_IV_TOO_LARGE 124
|
||||
#define ASN1_R_LENGTH_ERROR 125
|
||||
#define ASN1_R_MISSING_SECOND_NUMBER 126
|
||||
#define ASN1_R_NON_HEX_CHARACTERS 127
|
||||
#define ASN1_R_NOT_ENOUGH_DATA 128
|
||||
#define ASN1_R_ODD_NUMBER_OF_CHARS 129
|
||||
#define ASN1_R_PARSING 130
|
||||
#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 131
|
||||
#define ASN1_R_SECOND_NUMBER_TOO_LARGE 132
|
||||
#define ASN1_R_SHORT_LINE 133
|
||||
#define ASN1_R_STRING_TOO_SHORT 134
|
||||
#define ASN1_R_TAG_VALUE_TOO_HIGH 135
|
||||
#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 136
|
||||
#define ASN1_R_TOO_LONG 137
|
||||
#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 138
|
||||
#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 139
|
||||
#define ASN1_R_UNKNOWN_ATTRIBUTE_TYPE 140
|
||||
#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 141
|
||||
#define ASN1_R_UNKNOWN_OBJECT_TYPE 142
|
||||
#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 143
|
||||
#define ASN1_R_UNSUPPORTED_CIPHER 144
|
||||
#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 145
|
||||
#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 146
|
||||
#define ASN1_R_UTCTIME_TOO_LONG 147
|
||||
#define ASN1_R_WRONG_PRINTABLE_TYPE 148
|
||||
#define ASN1_R_WRONG_TAG 149
|
||||
#define ASN1_R_WRONG_TYPE 150
|
||||
|
@@ -122,101 +122,6 @@ extern "C" {
|
||||
#define B_ASN1_BMPSTRING 0x0800
|
||||
#define B_ASN1_UNKNOWN 0x1000
|
||||
|
||||
#ifndef DEBUG
|
||||
|
||||
#define ASN1_INTEGER ASN1_STRING
|
||||
#define ASN1_BIT_STRING ASN1_STRING
|
||||
#define ASN1_OCTET_STRING ASN1_STRING
|
||||
#define ASN1_PRINTABLESTRING ASN1_STRING
|
||||
#define ASN1_T61STRING ASN1_STRING
|
||||
#define ASN1_IA5STRING ASN1_STRING
|
||||
#define ASN1_UTCTIME ASN1_STRING
|
||||
#define ASN1_GENERALIZEDTIME ASN1_STRING
|
||||
#define ASN1_GENERALSTRING ASN1_STRING
|
||||
#define ASN1_UNIVERSALSTRING ASN1_STRING
|
||||
#define ASN1_BMPSTRING ASN1_STRING
|
||||
|
||||
#else
|
||||
|
||||
typedef struct asn1_integer_st
|
||||
{
|
||||
int length;
|
||||
int type;
|
||||
unsigned char *data;
|
||||
} ASN1_INTEGER;
|
||||
|
||||
typedef struct asn1_bit_string_st
|
||||
{
|
||||
int length;
|
||||
int type;
|
||||
unsigned char *data;
|
||||
} ASN1_BIT_STRING;
|
||||
|
||||
typedef struct asn1_octet_string_st
|
||||
{
|
||||
int length;
|
||||
int type;
|
||||
unsigned char *data;
|
||||
} ASN1_OCTET_STRING;
|
||||
|
||||
typedef struct asn1_printablestring_st
|
||||
{
|
||||
int length;
|
||||
int type;
|
||||
unsigned char *data;
|
||||
} ASN1_PRINTABLESTRING;
|
||||
|
||||
typedef struct asn1_t61string_st
|
||||
{
|
||||
int length;
|
||||
int type;
|
||||
unsigned char *data;
|
||||
} ASN1_T61STRING;
|
||||
|
||||
typedef struct asn1_ia5string_st
|
||||
{
|
||||
int length;
|
||||
int type;
|
||||
unsigned char *data;
|
||||
} ASN1_IA5STRING;
|
||||
|
||||
typedef struct asn1_generalstring_st
|
||||
{
|
||||
int length;
|
||||
int type;
|
||||
unsigned char *data;
|
||||
} ASN1_GENERALSTRING;
|
||||
|
||||
typedef struct asn1_universalstring_st
|
||||
{
|
||||
int length;
|
||||
int type;
|
||||
unsigned char *data;
|
||||
} ASN1_UNIVERSALSTRING;
|
||||
|
||||
typedef struct asn1_bmpstring_st
|
||||
{
|
||||
int length;
|
||||
int type;
|
||||
unsigned char *data;
|
||||
} ASN1_BMPSTRING;
|
||||
|
||||
typedef struct asn1_utctime_st
|
||||
{
|
||||
int length;
|
||||
int type;
|
||||
unsigned char *data;
|
||||
} ASN1_UTCTIME;
|
||||
|
||||
typedef struct asn1_generalizedtime_st
|
||||
{
|
||||
int length;
|
||||
int type;
|
||||
unsigned char *data;
|
||||
} ASN1_GENERALIZEDTIME;
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct asn1_ctx_st
|
||||
{
|
||||
unsigned char *p;/* work char pointer */
|
||||
@@ -229,6 +134,7 @@ typedef struct asn1_ctx_st
|
||||
unsigned char *max; /* largest value of p alowed */
|
||||
unsigned char *q;/* temporary variable */
|
||||
unsigned char **pp;/* variable */
|
||||
int line; /* used in error processing */
|
||||
} ASN1_CTX;
|
||||
|
||||
/* These are used internally in the ASN1_OBJECT to keep track of
|
||||
@@ -246,14 +152,46 @@ typedef struct asn1_object_st
|
||||
int flags; /* Should we free this one */
|
||||
} ASN1_OBJECT;
|
||||
|
||||
#define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */
|
||||
/* This is the base type that holds just about everything :-) */
|
||||
typedef struct asn1_string_st
|
||||
{
|
||||
int length;
|
||||
int type;
|
||||
unsigned char *data;
|
||||
/* The value of the following field depends on the type being
|
||||
* held. It is mostly being used for BIT_STRING so if the
|
||||
* input data has a non-zero 'unused bits' value, it will be
|
||||
* handled correctly */
|
||||
long flags;
|
||||
} ASN1_STRING;
|
||||
|
||||
#ifndef DEBUG
|
||||
#define ASN1_INTEGER ASN1_STRING
|
||||
#define ASN1_BIT_STRING ASN1_STRING
|
||||
#define ASN1_OCTET_STRING ASN1_STRING
|
||||
#define ASN1_PRINTABLESTRING ASN1_STRING
|
||||
#define ASN1_T61STRING ASN1_STRING
|
||||
#define ASN1_IA5STRING ASN1_STRING
|
||||
#define ASN1_UTCTIME ASN1_STRING
|
||||
#define ASN1_GENERALIZEDTIME ASN1_STRING
|
||||
#define ASN1_GENERALSTRING ASN1_STRING
|
||||
#define ASN1_UNIVERSALSTRING ASN1_STRING
|
||||
#define ASN1_BMPSTRING ASN1_STRING
|
||||
#else
|
||||
typedef struct asn1_string_st ASN1_INTEGER;
|
||||
typedef struct asn1_string_st ASN1_BIT_STRING;
|
||||
typedef struct asn1_string_st ASN1_OCTET_STRING;
|
||||
typedef struct asn1_string_st ASN1_PRINTABLESTRING;
|
||||
typedef struct asn1_string_st ASN1_T61STRING;
|
||||
typedef struct asn1_string_st ASN1_IA5STRING;
|
||||
typedef struct asn1_string_st ASN1_GENERALSTRING;
|
||||
typedef struct asn1_string_st ASN1_UNIVERSALSTRING;
|
||||
typedef struct asn1_string_st ASN1_BMPSTRING;
|
||||
typedef struct asn1_string_st ASN1_UTCTIME;
|
||||
typedef struct asn1_string_st ASN1_GENERALIZEDTIME;
|
||||
#endif
|
||||
|
||||
typedef struct asn1_type_st
|
||||
{
|
||||
int type;
|
||||
@@ -472,6 +410,10 @@ int i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a,unsigned char **pp);
|
||||
ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a,
|
||||
unsigned char **pp,long length);
|
||||
|
||||
int i2d_ASN1_BMPSTRING(ASN1_BMPSTRING *a, unsigned char **pp);
|
||||
ASN1_BMPSTRING *d2i_ASN1_BMPSTRING(ASN1_BMPSTRING **a, unsigned char **pp,
|
||||
long length);
|
||||
|
||||
int i2d_ASN1_PRINTABLE(ASN1_STRING *a,unsigned char **pp);
|
||||
ASN1_STRING *d2i_ASN1_PRINTABLE(ASN1_STRING **a,
|
||||
unsigned char **pp, long l);
|
||||
@@ -491,7 +433,8 @@ ASN1_UTCTIME * d2i_ASN1_UTCTIME(ASN1_UTCTIME **a,unsigned char **pp,
|
||||
int i2d_ASN1_SET(STACK *a, unsigned char **pp,
|
||||
int (*func)(), int ex_tag, int ex_class);
|
||||
STACK * d2i_ASN1_SET(STACK **a, unsigned char **pp, long length,
|
||||
char *(*func)(), int ex_tag, int ex_class);
|
||||
char *(*func)(), void (*free_func)(),
|
||||
int ex_tag, int ex_class);
|
||||
|
||||
#ifdef HEADER_BIO_H
|
||||
int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);
|
||||
@@ -666,6 +609,9 @@ int ASN1_TYPE_get_octetstring();
|
||||
int ASN1_TYPE_set_int_octetstring();
|
||||
int ASN1_TYPE_get_int_octetstring();
|
||||
|
||||
int i2d_ASN1_BMPSTRING();
|
||||
ASN1_BMPSTRING *d2i_ASN1_BMPSTRING();
|
||||
|
||||
#endif
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
@@ -797,60 +743,56 @@ int ASN1_TYPE_get_int_octetstring();
|
||||
|
||||
/* Reason codes. */
|
||||
#define ASN1_R_BAD_CLASS 100
|
||||
#define ASN1_R_BAD_GET_OBJECT 101
|
||||
#define ASN1_R_BAD_OBJECT_HEADER 102
|
||||
#define ASN1_R_BAD_PASSWORD_READ 103
|
||||
#define ASN1_R_BAD_PKCS7_CONTENT 104
|
||||
#define ASN1_R_BAD_PKCS7_TYPE 105
|
||||
#define ASN1_R_BAD_TAG 106
|
||||
#define ASN1_R_BAD_TYPE 107
|
||||
#define ASN1_R_BN_LIB 108
|
||||
#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 109
|
||||
#define ASN1_R_BUFFER_TOO_SMALL 110
|
||||
#define ASN1_R_DATA_IS_WRONG 111
|
||||
#define ASN1_R_DECODING_ERROR 112
|
||||
#define ASN1_R_ERROR_STACK 113
|
||||
#define ASN1_R_EXPECTING_AN_INTEGER 114
|
||||
#define ASN1_R_EXPECTING_AN_OBJECT 115
|
||||
#define ASN1_R_EXPECTING_AN_OCTET_STRING 116
|
||||
#define ASN1_R_EXPECTING_A_BIT_STRING 117
|
||||
#define ASN1_R_EXPECTING_A_BOOLEAN 118
|
||||
#define ASN1_R_EXPECTING_A_SEQUENCE 119
|
||||
#define ASN1_R_EXPECTING_A_UTCTIME 120
|
||||
#define ASN1_R_FIRST_NUM_TOO_LARGE 121
|
||||
#define ASN1_R_HEADER_TOO_LONG 122
|
||||
#define ASN1_R_INVALID_DIGIT 123
|
||||
#define ASN1_R_INVALID_SEPARATOR 124
|
||||
#define ASN1_R_INVALID_TIME_FORMAT 125
|
||||
#define ASN1_R_IV_TOO_LARGE 126
|
||||
#define ASN1_R_LENGTH_ERROR 127
|
||||
#define ASN1_R_LENGTH_MISMATCH 128
|
||||
#define ASN1_R_MISSING_EOS 129
|
||||
#define ASN1_R_MISSING_SECOND_NUMBER 130
|
||||
#define ASN1_R_NON_HEX_CHARACTERS 131
|
||||
#define ASN1_R_NOT_ENOUGH_DATA 132
|
||||
#define ASN1_R_ODD_NUMBER_OF_CHARS 133
|
||||
#define ASN1_R_PARSING 134
|
||||
#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 135
|
||||
#define ASN1_R_SECOND_NUMBER_TOO_LARGE 136
|
||||
#define ASN1_R_SHORT_LINE 137
|
||||
#define ASN1_R_STRING_TOO_SHORT 138
|
||||
#define ASN1_R_TAG_VALUE_TOO_HIGH 139
|
||||
#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 140
|
||||
#define ASN1_R_TOO_LONG 141
|
||||
#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 142
|
||||
#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 143
|
||||
#define ASN1_R_UNKNOWN_ATTRIBUTE_TYPE 144
|
||||
#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 145
|
||||
#define ASN1_R_UNKNOWN_OBJECT_TYPE 146
|
||||
#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 147
|
||||
#define ASN1_R_UNSUPPORTED_CIPHER 148
|
||||
#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 149
|
||||
#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 150
|
||||
#define ASN1_R_UTCTIME_TOO_LONG 151
|
||||
#define ASN1_R_WRONG_PRINTABLE_TYPE 152
|
||||
#define ASN1_R_WRONG_TAG 153
|
||||
#define ASN1_R_WRONG_TYPE 154
|
||||
#define ASN1_R_BAD_OBJECT_HEADER 101
|
||||
#define ASN1_R_BAD_PASSWORD_READ 102
|
||||
#define ASN1_R_BAD_PKCS7_CONTENT 103
|
||||
#define ASN1_R_BAD_PKCS7_TYPE 104
|
||||
#define ASN1_R_BAD_TAG 105
|
||||
#define ASN1_R_BAD_TYPE 106
|
||||
#define ASN1_R_BN_LIB 107
|
||||
#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 108
|
||||
#define ASN1_R_BUFFER_TOO_SMALL 109
|
||||
#define ASN1_R_DATA_IS_WRONG 110
|
||||
#define ASN1_R_DECODING_ERROR 111
|
||||
#define ASN1_R_ERROR_PARSING_SET_ELEMENT 112
|
||||
#define ASN1_R_EXPECTING_AN_INTEGER 113
|
||||
#define ASN1_R_EXPECTING_AN_OBJECT 114
|
||||
#define ASN1_R_EXPECTING_AN_OCTET_STRING 115
|
||||
#define ASN1_R_EXPECTING_A_BIT_STRING 116
|
||||
#define ASN1_R_EXPECTING_A_BOOLEAN 117
|
||||
#define ASN1_R_EXPECTING_A_UTCTIME 118
|
||||
#define ASN1_R_FIRST_NUM_TOO_LARGE 119
|
||||
#define ASN1_R_HEADER_TOO_LONG 120
|
||||
#define ASN1_R_INVALID_DIGIT 121
|
||||
#define ASN1_R_INVALID_SEPARATOR 122
|
||||
#define ASN1_R_INVALID_TIME_FORMAT 123
|
||||
#define ASN1_R_IV_TOO_LARGE 124
|
||||
#define ASN1_R_LENGTH_ERROR 125
|
||||
#define ASN1_R_MISSING_SECOND_NUMBER 126
|
||||
#define ASN1_R_NON_HEX_CHARACTERS 127
|
||||
#define ASN1_R_NOT_ENOUGH_DATA 128
|
||||
#define ASN1_R_ODD_NUMBER_OF_CHARS 129
|
||||
#define ASN1_R_PARSING 130
|
||||
#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 131
|
||||
#define ASN1_R_SECOND_NUMBER_TOO_LARGE 132
|
||||
#define ASN1_R_SHORT_LINE 133
|
||||
#define ASN1_R_STRING_TOO_SHORT 134
|
||||
#define ASN1_R_TAG_VALUE_TOO_HIGH 135
|
||||
#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 136
|
||||
#define ASN1_R_TOO_LONG 137
|
||||
#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 138
|
||||
#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 139
|
||||
#define ASN1_R_UNKNOWN_ATTRIBUTE_TYPE 140
|
||||
#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 141
|
||||
#define ASN1_R_UNKNOWN_OBJECT_TYPE 142
|
||||
#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 143
|
||||
#define ASN1_R_UNSUPPORTED_CIPHER 144
|
||||
#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 145
|
||||
#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 146
|
||||
#define ASN1_R_UTCTIME_TOO_LONG 147
|
||||
#define ASN1_R_WRONG_PRINTABLE_TYPE 148
|
||||
#define ASN1_R_WRONG_TAG 149
|
||||
#define ASN1_R_WRONG_TYPE 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@@ -87,7 +87,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
|
||||
{ERR_PACK(0,ASN1_F_ASN1_VERIFY,0), "ASN1_VERIFY"},
|
||||
{ERR_PACK(0,ASN1_F_BN_TO_ASN1_INTEGER,0), "BN_to_ASN1_INTEGER"},
|
||||
{ERR_PACK(0,ASN1_F_D2I_ASN1_BIT_STRING,0), "d2i_ASN1_BIT_STRING"},
|
||||
{ERR_PACK(0,ASN1_F_D2I_ASN1_BMPSTRING,0), "D2I_ASN1_BMPSTRING"},
|
||||
{ERR_PACK(0,ASN1_F_D2I_ASN1_BMPSTRING,0), "d2i_ASN1_BMPSTRING"},
|
||||
{ERR_PACK(0,ASN1_F_D2I_ASN1_BOOLEAN,0), "d2i_ASN1_BOOLEAN"},
|
||||
{ERR_PACK(0,ASN1_F_D2I_ASN1_BYTES,0), "d2i_ASN1_bytes"},
|
||||
{ERR_PACK(0,ASN1_F_D2I_ASN1_HEADER,0), "d2i_ASN1_HEADER"},
|
||||
@@ -191,7 +191,6 @@ static ERR_STRING_DATA ASN1_str_functs[]=
|
||||
static ERR_STRING_DATA ASN1_str_reasons[]=
|
||||
{
|
||||
{ASN1_R_BAD_CLASS ,"bad class"},
|
||||
{ASN1_R_BAD_GET_OBJECT ,"bad get object"},
|
||||
{ASN1_R_BAD_OBJECT_HEADER ,"bad object header"},
|
||||
{ASN1_R_BAD_PASSWORD_READ ,"bad password read"},
|
||||
{ASN1_R_BAD_PKCS7_CONTENT ,"bad pkcs7 content"},
|
||||
@@ -203,13 +202,12 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
|
||||
{ASN1_R_BUFFER_TOO_SMALL ,"buffer too small"},
|
||||
{ASN1_R_DATA_IS_WRONG ,"data is wrong"},
|
||||
{ASN1_R_DECODING_ERROR ,"decoding error"},
|
||||
{ASN1_R_ERROR_STACK ,"error stack"},
|
||||
{ASN1_R_ERROR_PARSING_SET_ELEMENT ,"error parsing set element"},
|
||||
{ASN1_R_EXPECTING_AN_INTEGER ,"expecting an integer"},
|
||||
{ASN1_R_EXPECTING_AN_OBJECT ,"expecting an object"},
|
||||
{ASN1_R_EXPECTING_AN_OCTET_STRING ,"expecting an octet string"},
|
||||
{ASN1_R_EXPECTING_A_BIT_STRING ,"expecting a bit string"},
|
||||
{ASN1_R_EXPECTING_A_BOOLEAN ,"expecting a boolean"},
|
||||
{ASN1_R_EXPECTING_A_SEQUENCE ,"expecting a sequence"},
|
||||
{ASN1_R_EXPECTING_A_UTCTIME ,"expecting a utctime"},
|
||||
{ASN1_R_FIRST_NUM_TOO_LARGE ,"first num too large"},
|
||||
{ASN1_R_HEADER_TOO_LONG ,"header too long"},
|
||||
@@ -218,8 +216,6 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
|
||||
{ASN1_R_INVALID_TIME_FORMAT ,"invalid time format"},
|
||||
{ASN1_R_IV_TOO_LARGE ,"iv too large"},
|
||||
{ASN1_R_LENGTH_ERROR ,"length error"},
|
||||
{ASN1_R_LENGTH_MISMATCH ,"length mismatch"},
|
||||
{ASN1_R_MISSING_EOS ,"missing eos"},
|
||||
{ASN1_R_MISSING_SECOND_NUMBER ,"missing second number"},
|
||||
{ASN1_R_NON_HEX_CHARACTERS ,"non hex characters"},
|
||||
{ASN1_R_NOT_ENOUGH_DATA ,"not enough data"},
|
||||
@@ -254,8 +250,8 @@ void ERR_load_ASN1_strings()
|
||||
{
|
||||
static int init=1;
|
||||
|
||||
if (init);
|
||||
{;
|
||||
if (init)
|
||||
{
|
||||
init=0;
|
||||
#ifndef NO_ERR
|
||||
ERR_load_strings(ERR_LIB_ASN1,ASN1_str_functs);
|
||||
|
@@ -69,7 +69,7 @@ static int asn1_get_length();
|
||||
static void asn1_put_length();
|
||||
#endif
|
||||
|
||||
char *ASN1_version="ASN1 part of SSLeay 0.9.0b 29-Jun-1998";
|
||||
char *ASN1_version="ASN1 part of SSLeay 0.9.1a 06-Jul-1998";
|
||||
|
||||
int ASN1_check_infinite_end(p,len)
|
||||
unsigned char **p;
|
||||
@@ -130,11 +130,13 @@ long omax;
|
||||
*pclass=xclass;
|
||||
if (!asn1_get_length(&p,&inf,plength,(int)max)) goto err;
|
||||
|
||||
#ifdef undef
|
||||
fprintf(stderr,"p=%d + *plength=%d > omax=%d + *pp=%d (%d > %d)\n",
|
||||
p,*plength,omax,*pp,(p+ *plength),omax+ *pp);
|
||||
#if 0
|
||||
fprintf(stderr,"p=%d + *plength=%ld > omax=%ld + *pp=%d (%d > %d)\n",
|
||||
(int)p,*plength,omax,(int)*pp,(int)(p+ *plength),
|
||||
(int)(omax+ *pp));
|
||||
|
||||
#endif
|
||||
#if 0
|
||||
if ((p+ *plength) > (omax+ *pp))
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_TOO_LONG);
|
||||
@@ -142,8 +144,9 @@ long omax;
|
||||
* the values are set correctly */
|
||||
ret|=0x80;
|
||||
}
|
||||
#endif
|
||||
*pp=p;
|
||||
return(ret+inf);
|
||||
return(ret|inf);
|
||||
err:
|
||||
ASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_HEADER_TOO_LONG);
|
||||
return(0x80);
|
||||
@@ -284,14 +287,14 @@ ASN1_CTX *c;
|
||||
{
|
||||
if (!ASN1_check_infinite_end(&c->p,c->slen))
|
||||
{
|
||||
c->error=ASN1_R_MISSING_EOS;
|
||||
c->error=ERR_R_MISSING_ASN1_EOS;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
if ( ((c->slen != 0) && !(c->inf & 1)) ||
|
||||
((c->slen < 0) && (c->inf & 1)))
|
||||
{
|
||||
c->error=ASN1_R_LENGTH_MISMATCH;
|
||||
c->error=ERR_R_ASN1_LENGTH_MISMATCH;
|
||||
return(0);
|
||||
}
|
||||
return(1);
|
||||
@@ -308,18 +311,18 @@ long *length;
|
||||
*length);
|
||||
if (c->inf & 0x80)
|
||||
{
|
||||
c->error=ASN1_R_BAD_GET_OBJECT;
|
||||
c->error=ERR_R_BAD_GET_ASN1_OBJECT_CALL;
|
||||
return(0);
|
||||
}
|
||||
if (c->tag != V_ASN1_SEQUENCE)
|
||||
{
|
||||
c->error=ASN1_R_EXPECTING_A_SEQUENCE;
|
||||
c->error=ERR_R_EXPECTING_AN_ASN1_SEQUENCE;
|
||||
return(0);
|
||||
}
|
||||
(*length)-=(c->p-q);
|
||||
if (c->max && (*length < 0))
|
||||
{
|
||||
c->error=ASN1_R_LENGTH_MISMATCH;
|
||||
c->error=ERR_R_ASN1_LENGTH_MISMATCH;
|
||||
return(0);
|
||||
}
|
||||
if (c->inf == (1|V_ASN1_CONSTRUCTED))
|
||||
@@ -402,6 +405,7 @@ int type;
|
||||
ret->length=0;
|
||||
ret->type=type;
|
||||
ret->data=NULL;
|
||||
ret->flags=0;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
@@ -67,14 +67,23 @@ extern "C" {
|
||||
#include "x509.h"
|
||||
#include "pkcs7.h"
|
||||
|
||||
#ifndef ASN1_MAC_ERR_LIB
|
||||
#define ASN1_MAC_ERR_LIB ERR_LIB_ASN1
|
||||
#endif
|
||||
|
||||
#define ASN1_MAC_H_err(f,r,line) \
|
||||
ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),ERR_file_name,(line))
|
||||
|
||||
#define M_ASN1_D2I_vars(a,type,func) \
|
||||
ASN1_CTX c; \
|
||||
type ret=NULL; \
|
||||
\
|
||||
c.pp=pp; \
|
||||
c.error=ASN1_R_ERROR_STACK; \
|
||||
c.q= *pp; \
|
||||
c.error=ERR_R_NESTED_ASN1_ERROR; \
|
||||
if ((a == NULL) || ((*a) == NULL)) \
|
||||
{ if ((ret=(type)func()) == NULL) goto err; } \
|
||||
{ if ((ret=(type)func()) == NULL) \
|
||||
{ c.line=__LINE__; goto err; } } \
|
||||
else ret=(*a);
|
||||
|
||||
#define M_ASN1_D2I_Init() \
|
||||
@@ -82,7 +91,8 @@ extern "C" {
|
||||
c.max=(length == 0)?0:(c.p+length);
|
||||
|
||||
#define M_ASN1_D2I_Finish_2(a) \
|
||||
if (!asn1_Finish(&c)) goto err; \
|
||||
if (!asn1_Finish(&c)) \
|
||||
{ c.line=__LINE__; goto err; } \
|
||||
*pp=c.p; \
|
||||
if (a != NULL) (*a)=ret; \
|
||||
return(ret);
|
||||
@@ -90,21 +100,31 @@ extern "C" {
|
||||
#define M_ASN1_D2I_Finish(a,func,e) \
|
||||
M_ASN1_D2I_Finish_2(a); \
|
||||
err:\
|
||||
ASN1err((e),c.error); \
|
||||
ASN1_MAC_H_err((e),c.error,c.line); \
|
||||
asn1_add_error(*pp,(int)(c.q- *pp)); \
|
||||
if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \
|
||||
return(NULL)
|
||||
|
||||
#define M_ASN1_D2I_start_sequence() \
|
||||
if (!asn1_GetSequence(&c,&length)) goto err;
|
||||
if (!asn1_GetSequence(&c,&length)) \
|
||||
{ c.line=__LINE__; goto err; }
|
||||
|
||||
#define M_ASN1_D2I_end_sequence() \
|
||||
(((c.inf&1) == 0)?(c.slen <= 0): \
|
||||
(c.eos=ASN1_check_infinite_end(&c.p,c.slen)))
|
||||
|
||||
/* Don't use this with d2i_ASN1_BOOLEAN() */
|
||||
#define M_ASN1_D2I_get(b,func) \
|
||||
c.q=c.p; \
|
||||
if (func(&(b),&c.p,c.slen) == NULL) goto err; \
|
||||
if (func(&(b),&c.p,c.slen) == NULL) \
|
||||
{c.line=__LINE__; goto err; } \
|
||||
c.slen-=(c.p-c.q);
|
||||
|
||||
/* use this instead () */
|
||||
#define M_ASN1_D2I_get_int(b,func) \
|
||||
c.q=c.p; \
|
||||
if (func(&(b),&c.p,c.slen) < 0) \
|
||||
{c.line=__LINE__; goto err; } \
|
||||
c.slen-=(c.p-c.q);
|
||||
|
||||
#define M_ASN1_D2I_get_opt(b,func,type) \
|
||||
@@ -125,38 +145,56 @@ err:\
|
||||
M_ASN1_next_prev=tmp; \
|
||||
}
|
||||
|
||||
#define M_ASN1_D2I_get_set(r,func) \
|
||||
M_ASN1_D2I_get_imp_set(r,func,V_ASN1_SET,V_ASN1_UNIVERSAL);
|
||||
#define M_ASN1_D2I_get_set(r,func,free_func) \
|
||||
M_ASN1_D2I_get_imp_set(r,func,free_func, \
|
||||
V_ASN1_SET,V_ASN1_UNIVERSAL);
|
||||
|
||||
#define M_ASN1_D2I_get_IMP_set_opt(b,func,tag) \
|
||||
#define M_ASN1_D2I_get_set_opt(r,func,free_func) \
|
||||
if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
|
||||
V_ASN1_CONSTRUCTED|V_ASN1_SET)))\
|
||||
{ M_ASN1_D2I_get_set(r,func,free_func); }
|
||||
|
||||
#define M_ASN1_I2D_len_SET_opt(a,f) \
|
||||
if ((a != NULL) && (sk_num(a) != 0)) \
|
||||
M_ASN1_I2D_len_SET(a,f);
|
||||
|
||||
#define M_ASN1_I2D_put_SET_opt(a,f) \
|
||||
if ((a != NULL) && (sk_num(a) != 0)) \
|
||||
M_ASN1_I2D_put_SET(a,f);
|
||||
|
||||
#define M_ASN1_D2I_get_IMP_set_opt(b,func,free_func,tag) \
|
||||
if ((c.slen != 0) && \
|
||||
(M_ASN1_next == \
|
||||
(V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\
|
||||
{ \
|
||||
M_ASN1_D2I_get_imp_set(b,func,tag,V_ASN1_CONTEXT_SPECIFIC); \
|
||||
M_ASN1_D2I_get_imp_set(b,func,free_func,\
|
||||
tag,V_ASN1_CONTEXT_SPECIFIC); \
|
||||
}
|
||||
|
||||
#define M_ASN1_D2I_get_seq(r,func) \
|
||||
M_ASN1_D2I_get_imp_set(r,func,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
|
||||
#define M_ASN1_D2I_get_seq(r,func,free_func) \
|
||||
M_ASN1_D2I_get_imp_set(r,func,free_func,\
|
||||
V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
|
||||
|
||||
#define M_ASN1_D2I_get_seq_opt(r,func) \
|
||||
#define M_ASN1_D2I_get_seq_opt(r,func,free_func) \
|
||||
if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
|
||||
V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\
|
||||
{ M_ASN1_D2I_get_seq(r,func); }
|
||||
{ M_ASN1_D2I_get_seq(r,func,free_func); }
|
||||
|
||||
#define M_ASN1_D2I_get_IMP_set(r,func,x) \
|
||||
M_ASN1_D2I_get_imp_set(r,func,x,V_ASN1_CONTEXT_SPECIFIC);
|
||||
#define M_ASN1_D2I_get_IMP_set(r,func,free_func,x) \
|
||||
M_ASN1_D2I_get_imp_set(r,func,free_func,\
|
||||
x,V_ASN1_CONTEXT_SPECIFIC);
|
||||
|
||||
#define M_ASN1_D2I_get_imp_set(r,func,a,b) \
|
||||
#define M_ASN1_D2I_get_imp_set(r,func,free_func,a,b) \
|
||||
c.q=c.p; \
|
||||
if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,a,b) == NULL) \
|
||||
goto err; \
|
||||
if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\
|
||||
(void (*)())free_func,a,b) == NULL) \
|
||||
{ c.line=__LINE__; goto err; } \
|
||||
c.slen-=(c.p-c.q);
|
||||
|
||||
#define M_ASN1_D2I_get_set_strings(r,func,a,b) \
|
||||
c.q=c.p; \
|
||||
if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \
|
||||
goto err; \
|
||||
{ c.line=__LINE__; goto err; } \
|
||||
c.slen-=(c.p-c.q);
|
||||
|
||||
#define M_ASN1_D2I_get_EXP_opt(r,func,tag) \
|
||||
@@ -169,13 +207,14 @@ err:\
|
||||
c.q=c.p; \
|
||||
Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
|
||||
if (Tinf & 0x80) \
|
||||
{ c.error=ASN1_R_BAD_OBJECT_HEADER; goto err; } \
|
||||
{ c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
|
||||
c.line=__LINE__; goto err; } \
|
||||
if (func(&(r),&c.p,Tlen) == NULL) \
|
||||
goto err; \
|
||||
{ c.line=__LINE__; goto err; } \
|
||||
c.slen-=(c.p-c.q); \
|
||||
}
|
||||
|
||||
#define M_ASN1_D2I_get_EXP_set_opt(r,func,tag,b) \
|
||||
#define M_ASN1_D2I_get_EXP_set_opt(r,func,free_func,tag,b) \
|
||||
if ((c.slen != 0) && (M_ASN1_next == \
|
||||
(V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \
|
||||
{ \
|
||||
@@ -185,24 +224,27 @@ err:\
|
||||
c.q=c.p; \
|
||||
Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
|
||||
if (Tinf & 0x80) \
|
||||
{ c.error=ASN1_R_BAD_OBJECT_HEADER; goto err; } \
|
||||
{ c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
|
||||
c.line=__LINE__; goto err; } \
|
||||
if (d2i_ASN1_SET(&(r),&c.p,Tlen,(char *(*)())func, \
|
||||
(void (*)())free_func, \
|
||||
b,V_ASN1_UNIVERSAL) == NULL) \
|
||||
goto err; \
|
||||
{ c.line=__LINE__; goto err; } \
|
||||
c.slen-=(c.p-c.q); \
|
||||
}
|
||||
|
||||
/* New macros */
|
||||
#define M_ASN1_New_Malloc(ret,type) \
|
||||
if ((ret=(type *)Malloc(sizeof(type))) == NULL) goto err2;
|
||||
if ((ret=(type *)Malloc(sizeof(type))) == NULL) \
|
||||
{ c.line=__LINE__; goto err2; }
|
||||
|
||||
#define M_ASN1_New(arg,func) \
|
||||
if (((arg)=func()) == NULL) return(NULL)
|
||||
|
||||
#define M_ASN1_New_Error(a) \
|
||||
/* err: ASN1err((a),ASN1_R_ERROR_STACK); \
|
||||
/* err: ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \
|
||||
return(NULL);*/ \
|
||||
err2: ASN1err((a),ERR_R_MALLOC_FAILURE); \
|
||||
err2: ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \
|
||||
return(NULL)
|
||||
|
||||
|
||||
|
@@ -266,7 +266,8 @@ int indent;
|
||||
if ( (tag == V_ASN1_PRINTABLESTRING) ||
|
||||
(tag == V_ASN1_T61STRING) ||
|
||||
(tag == V_ASN1_IA5STRING) ||
|
||||
(tag == V_ASN1_UTCTIME))
|
||||
(tag == V_ASN1_UTCTIME) ||
|
||||
(tag == V_ASN1_GENERALIZEDTIME))
|
||||
{
|
||||
if (BIO_write(bp,":",1) <= 0) goto end;
|
||||
if ((len > 0) &&
|
||||
|
@@ -64,7 +64,7 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_DHPARAMS,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_DHPARAMS,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_I2D_DHPARAMS,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
|
||||
*/
|
||||
|
||||
@@ -73,7 +73,7 @@ DH **a;
|
||||
unsigned char **pp;
|
||||
long length;
|
||||
{
|
||||
int i=ASN1_R_ERROR_STACK;
|
||||
int i=ERR_R_NESTED_ASN1_ERROR;
|
||||
ASN1_INTEGER *bs=NULL;
|
||||
long v=0;
|
||||
M_ASN1_D2I_vars(a,DH *,DH_new);
|
||||
|
@@ -64,7 +64,7 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_DSAPARAMS,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_DSAPARAMS,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_I2D_DSAPARAMS,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
|
||||
*/
|
||||
|
||||
@@ -73,7 +73,7 @@ DSA **a;
|
||||
unsigned char **pp;
|
||||
long length;
|
||||
{
|
||||
int i=ASN1_R_ERROR_STACK;
|
||||
int i=ERR_R_NESTED_ASN1_ERROR;
|
||||
ASN1_INTEGER *bs=NULL;
|
||||
M_ASN1_D2I_vars(a,DSA *,DSA_new);
|
||||
|
||||
|
@@ -106,7 +106,7 @@ long length;
|
||||
default:
|
||||
ASN1err(ASN1_F_D2I_PRIVATEKEY,ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE);
|
||||
goto err;
|
||||
break;
|
||||
/* break; */
|
||||
}
|
||||
if (a != NULL) (*a)=ret;
|
||||
return(ret);
|
||||
|
@@ -106,7 +106,7 @@ long length;
|
||||
default:
|
||||
ASN1err(ASN1_F_D2I_PUBLICKEY,ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE);
|
||||
goto err;
|
||||
break;
|
||||
/* break; */
|
||||
}
|
||||
if (a != NULL) (*a)=ret;
|
||||
return(ret);
|
||||
|
@@ -64,7 +64,7 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
|
||||
* ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ASN1_R_PARSING);
|
||||
*/
|
||||
|
@@ -64,7 +64,7 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_RSAPUBLICKEY,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_RSAPUBLICKEY,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_I2D_RSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
|
||||
*/
|
||||
|
||||
|
@@ -66,7 +66,7 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_DSAPRIVATEKEY,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_DSAPRIVATEKEY,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
|
||||
* ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ASN1_R_PARSING);
|
||||
*/
|
||||
|
@@ -66,7 +66,7 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_DSAPUBLICKEY,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_DSAPUBLICKEY,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_I2D_DSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
|
||||
*/
|
||||
|
||||
|
@@ -135,7 +135,8 @@ int len;
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* we return the actual length... */
|
||||
/* we return the actual length..., num may be missing, in which
|
||||
* case, set it to zero */
|
||||
int ASN1_TYPE_get_int_octetstring(a,num,data,max_len)
|
||||
ASN1_TYPE *a;
|
||||
long *num;
|
||||
|
@@ -63,8 +63,8 @@
|
||||
#include "dh.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_DHPARAMS,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_DHPARAMS_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_DHPARAMS,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_DHPARAMS_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_DHparams(a,pp)
|
||||
|
@@ -63,7 +63,7 @@
|
||||
#include "dsa.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_DSAPARAMS,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_DSAPARAMS,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_DSAparams(a,pp)
|
||||
|
@@ -64,7 +64,7 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
|
||||
*/
|
||||
|
||||
|
@@ -64,7 +64,7 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_RSAPUBLICKEY,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_RSAPUBLICKEY,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_I2D_RSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
|
||||
*/
|
||||
|
||||
|
@@ -75,7 +75,7 @@ typedef struct netscape_pkey_st
|
||||
} NETSCAPE_PKEY;
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_NETSCAPE_RSA,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_NETSCAPE_RSA,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_NETSCAPE_RSA,ASN1_R_DECODING_ERROR);
|
||||
* ASN1err(ASN1_F_D2I_NETSCAPE_PKEY,ASN1_R_DECODING_ERROR);
|
||||
* ASN1err(ASN1_F_NETSCAPE_PKEY_NEW,ASN1_R_DECODING_ERROR);
|
||||
@@ -249,7 +249,7 @@ int (*cb)();
|
||||
ASN1_OCTET_STRING *os=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
c.error=ASN1_R_ERROR_STACK;
|
||||
c.error=ERR_R_NESTED_ASN1_ERROR;
|
||||
c.pp=pp;
|
||||
|
||||
M_ASN1_D2I_Init();
|
||||
@@ -342,6 +342,7 @@ long length;
|
||||
static NETSCAPE_PKEY *NETSCAPE_PKEY_new()
|
||||
{
|
||||
NETSCAPE_PKEY *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,NETSCAPE_PKEY);
|
||||
M_ASN1_New(ret->version,ASN1_INTEGER_new);
|
||||
|
@@ -62,8 +62,8 @@
|
||||
#include "x509.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_PKCS7_DIGEST_NEW,ASN1_R_MISSING_EOS);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_DIGEST,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_PKCS7_DIGEST_NEW,ERR_R_MISSING_ASN1_EOS);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_DIGEST,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_PKCS7_DIGEST(a,pp)
|
||||
@@ -107,6 +107,7 @@ long length;
|
||||
PKCS7_DIGEST *PKCS7_DIGEST_new()
|
||||
{
|
||||
PKCS7_DIGEST *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,PKCS7_DIGEST);
|
||||
M_ASN1_New(ret->version,ASN1_INTEGER_new);
|
||||
|
@@ -62,8 +62,8 @@
|
||||
#include "x509.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_PKCS7_ENCRYPT_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_ENCRYPT,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_PKCS7_ENCRYPT_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_ENCRYPT,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_PKCS7_ENCRYPT(a,pp)
|
||||
@@ -101,6 +101,7 @@ long length;
|
||||
PKCS7_ENCRYPT *PKCS7_ENCRYPT_new()
|
||||
{
|
||||
PKCS7_ENCRYPT *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,PKCS7_ENCRYPT);
|
||||
M_ASN1_New(ret->version,ASN1_INTEGER_new);
|
||||
|
@@ -62,8 +62,8 @@
|
||||
#include "x509.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_PKCS7_ENC_CONTENT_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_ENC_CONTENT,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_PKCS7_ENC_CONTENT_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_ENC_CONTENT,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_PKCS7_ENC_CONTENT(a,pp)
|
||||
@@ -106,9 +106,11 @@ long length;
|
||||
PKCS7_ENC_CONTENT *PKCS7_ENC_CONTENT_new()
|
||||
{
|
||||
PKCS7_ENC_CONTENT *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,PKCS7_ENC_CONTENT);
|
||||
M_ASN1_New(ret->content_type,ASN1_OBJECT_new);
|
||||
/* M_ASN1_New(ret->content_type,ASN1_OBJECT_new); */
|
||||
ret->content_type=OBJ_nid2obj(NID_pkcs7_encrypted);
|
||||
M_ASN1_New(ret->algorithm,X509_ALGOR_new);
|
||||
ret->enc_data=NULL;
|
||||
return(ret);
|
||||
|
@@ -62,8 +62,8 @@
|
||||
#include "x509.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_PKCS7_ENVELOPE_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_ENVELOPE,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_PKCS7_ENVELOPE_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_ENVELOPE,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_PKCS7_ENVELOPE(a,pp)
|
||||
@@ -95,7 +95,8 @@ long length;
|
||||
M_ASN1_D2I_Init();
|
||||
M_ASN1_D2I_start_sequence();
|
||||
M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
|
||||
M_ASN1_D2I_get_set(ret->recipientinfo,d2i_PKCS7_RECIP_INFO);
|
||||
M_ASN1_D2I_get_set(ret->recipientinfo,d2i_PKCS7_RECIP_INFO,
|
||||
PKCS7_RECIP_INFO_free);
|
||||
M_ASN1_D2I_get(ret->enc_data,d2i_PKCS7_ENC_CONTENT);
|
||||
|
||||
M_ASN1_D2I_Finish(a,PKCS7_ENVELOPE_free,ASN1_F_D2I_PKCS7_ENVELOPE);
|
||||
@@ -104,6 +105,7 @@ long length;
|
||||
PKCS7_ENVELOPE *PKCS7_ENVELOPE_new()
|
||||
{
|
||||
PKCS7_ENVELOPE *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,PKCS7_ENVELOPE);
|
||||
M_ASN1_New(ret->version,ASN1_INTEGER_new);
|
||||
|
@@ -62,8 +62,8 @@
|
||||
#include "x509.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_ISSUER_AND_SERIAL,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_ISSUER_AND_SERIAL,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_PKCS7_ISSUER_AND_SERIAL(a,pp)
|
||||
@@ -101,6 +101,7 @@ long length;
|
||||
PKCS7_ISSUER_AND_SERIAL *PKCS7_ISSUER_AND_SERIAL_new()
|
||||
{
|
||||
PKCS7_ISSUER_AND_SERIAL *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,PKCS7_ISSUER_AND_SERIAL);
|
||||
M_ASN1_New(ret->issuer,X509_NAME_new);
|
||||
|
@@ -179,6 +179,7 @@ long length;
|
||||
V_ASN1_CONTEXT_SPECIFIC|0))
|
||||
{
|
||||
c.error=ASN1_R_BAD_PKCS7_CONTENT;
|
||||
c.line=__LINE__;
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -187,7 +188,7 @@ long length;
|
||||
c.q=c.p;
|
||||
Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,
|
||||
(c.inf & 1)?(length+ *pp-c.q):c.slen);
|
||||
if (Tinf & 0x80) goto err;
|
||||
if (Tinf & 0x80) { c.line=__LINE__; goto err; }
|
||||
c.slen-=(c.p-c.q);
|
||||
|
||||
switch (OBJ_obj2nid(ret->type))
|
||||
@@ -215,14 +216,16 @@ long length;
|
||||
break;
|
||||
default:
|
||||
c.error=ASN1_R_BAD_PKCS7_TYPE;
|
||||
c.line=__LINE__;
|
||||
goto err;
|
||||
break;
|
||||
/* break; */
|
||||
}
|
||||
if (Tinf == (1|V_ASN1_CONSTRUCTED))
|
||||
{
|
||||
if (!ASN1_check_infinite_end(&c.p,c.slen))
|
||||
{
|
||||
c.error=ASN1_R_MISSING_EOS;
|
||||
c.error=ERR_R_MISSING_ASN1_EOS;
|
||||
c.line=__LINE__;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
@@ -236,9 +239,10 @@ long length;
|
||||
PKCS7 *PKCS7_new()
|
||||
{
|
||||
PKCS7 *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,PKCS7);
|
||||
ret->type=ASN1_OBJECT_new();
|
||||
ret->type=OBJ_nid2obj(NID_undef);
|
||||
ret->asn1=NULL;
|
||||
ret->length=0;
|
||||
ret->detached=0;
|
||||
|
@@ -62,8 +62,8 @@
|
||||
#include "x509.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_PKCS7_RECIP_INFO_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_RECIP_INFO,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_PKCS7_RECIP_INFO_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_RECIP_INFO,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_PKCS7_RECIP_INFO(a,pp)
|
||||
@@ -107,6 +107,7 @@ long length;
|
||||
PKCS7_RECIP_INFO *PKCS7_RECIP_INFO_new()
|
||||
{
|
||||
PKCS7_RECIP_INFO *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,PKCS7_RECIP_INFO);
|
||||
M_ASN1_New(ret->version,ASN1_INTEGER_new);
|
||||
|
@@ -62,8 +62,8 @@
|
||||
#include "x509.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_PKCS7_SIGN_ENVELOPE_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_SIGN_ENVELOPE,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_PKCS7_SIGN_ENVELOPE_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_SIGN_ENVELOPE,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_PKCS7_SIGN_ENVELOPE(a,pp)
|
||||
@@ -103,12 +103,14 @@ long length;
|
||||
M_ASN1_D2I_Init();
|
||||
M_ASN1_D2I_start_sequence();
|
||||
M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
|
||||
M_ASN1_D2I_get_set(ret->recipientinfo,d2i_PKCS7_RECIP_INFO);
|
||||
M_ASN1_D2I_get_set(ret->md_algs,d2i_X509_ALGOR);
|
||||
M_ASN1_D2I_get_set(ret->recipientinfo,d2i_PKCS7_RECIP_INFO,
|
||||
PKCS7_RECIP_INFO_free);
|
||||
M_ASN1_D2I_get_set(ret->md_algs,d2i_X509_ALGOR,X509_ALGOR_free);
|
||||
M_ASN1_D2I_get(ret->enc_data,d2i_PKCS7_ENC_CONTENT);
|
||||
M_ASN1_D2I_get_IMP_set_opt(ret->cert,d2i_X509,0);
|
||||
M_ASN1_D2I_get_IMP_set_opt(ret->crl,d2i_X509_CRL,1);
|
||||
M_ASN1_D2I_get_set(ret->signer_info,d2i_PKCS7_SIGNER_INFO);
|
||||
M_ASN1_D2I_get_IMP_set_opt(ret->cert,d2i_X509,X509_free,0);
|
||||
M_ASN1_D2I_get_IMP_set_opt(ret->crl,d2i_X509_CRL,X509_CRL_free,1);
|
||||
M_ASN1_D2I_get_set(ret->signer_info,d2i_PKCS7_SIGNER_INFO,
|
||||
PKCS7_SIGNER_INFO_free);
|
||||
|
||||
M_ASN1_D2I_Finish(a,PKCS7_SIGN_ENVELOPE_free,
|
||||
ASN1_F_D2I_PKCS7_SIGN_ENVELOPE);
|
||||
@@ -117,6 +119,7 @@ long length;
|
||||
PKCS7_SIGN_ENVELOPE *PKCS7_SIGN_ENVELOPE_new()
|
||||
{
|
||||
PKCS7_SIGN_ENVELOPE *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,PKCS7_SIGN_ENVELOPE);
|
||||
M_ASN1_New(ret->version,ASN1_INTEGER_new);
|
||||
|
@@ -62,8 +62,8 @@
|
||||
#include "x509.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_PKCS7_SIGNED_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_SIGNED,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_PKCS7_SIGNED_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_SIGNED,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_PKCS7_SIGNED(a,pp)
|
||||
@@ -101,11 +101,12 @@ long length;
|
||||
M_ASN1_D2I_Init();
|
||||
M_ASN1_D2I_start_sequence();
|
||||
M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
|
||||
M_ASN1_D2I_get_set(ret->md_algs,d2i_X509_ALGOR);
|
||||
M_ASN1_D2I_get_set(ret->md_algs,d2i_X509_ALGOR,X509_ALGOR_free);
|
||||
M_ASN1_D2I_get(ret->contents,d2i_PKCS7);
|
||||
M_ASN1_D2I_get_IMP_set_opt(ret->cert,d2i_X509,0);
|
||||
M_ASN1_D2I_get_IMP_set_opt(ret->crl,d2i_X509_CRL,1);
|
||||
M_ASN1_D2I_get_set(ret->signer_info,d2i_PKCS7_SIGNER_INFO);
|
||||
M_ASN1_D2I_get_IMP_set_opt(ret->cert,d2i_X509,X509_free,0);
|
||||
M_ASN1_D2I_get_IMP_set_opt(ret->crl,d2i_X509_CRL,X509_CRL_free,1);
|
||||
M_ASN1_D2I_get_set(ret->signer_info,d2i_PKCS7_SIGNER_INFO,
|
||||
PKCS7_SIGNER_INFO_free);
|
||||
|
||||
M_ASN1_D2I_Finish(a,PKCS7_SIGNED_free,ASN1_F_D2I_PKCS7_SIGNED);
|
||||
}
|
||||
@@ -113,6 +114,7 @@ long length;
|
||||
PKCS7_SIGNED *PKCS7_SIGNED_new()
|
||||
{
|
||||
PKCS7_SIGNED *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,PKCS7_SIGNED);
|
||||
M_ASN1_New(ret->version,ASN1_INTEGER_new);
|
||||
|
@@ -62,8 +62,8 @@
|
||||
#include "x509.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_PKCS7_SIGNER_INFO_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_SIGNER_INFO,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_PKCS7_SIGNER_INFO_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_PKCS7_SIGNER_INFO,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_PKCS7_SIGNER_INFO(a,pp)
|
||||
@@ -105,10 +105,12 @@ long length;
|
||||
M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
|
||||
M_ASN1_D2I_get(ret->issuer_and_serial,d2i_PKCS7_ISSUER_AND_SERIAL);
|
||||
M_ASN1_D2I_get(ret->digest_alg,d2i_X509_ALGOR);
|
||||
M_ASN1_D2I_get_IMP_set_opt(ret->auth_attr,d2i_X509_ATTRIBUTE,0);
|
||||
M_ASN1_D2I_get_IMP_set_opt(ret->auth_attr,d2i_X509_ATTRIBUTE,
|
||||
X509_ATTRIBUTE_free,0);
|
||||
M_ASN1_D2I_get(ret->digest_enc_alg,d2i_X509_ALGOR);
|
||||
M_ASN1_D2I_get(ret->enc_digest,d2i_ASN1_OCTET_STRING);
|
||||
M_ASN1_D2I_get_IMP_set_opt(ret->unauth_attr,d2i_X509_ATTRIBUTE,1);
|
||||
M_ASN1_D2I_get_IMP_set_opt(ret->unauth_attr,d2i_X509_ATTRIBUTE,
|
||||
X509_ATTRIBUTE_free,1);
|
||||
|
||||
M_ASN1_D2I_Finish(a,PKCS7_SIGNER_INFO_free,
|
||||
ASN1_F_D2I_PKCS7_SIGNER_INFO);
|
||||
@@ -117,6 +119,7 @@ long length;
|
||||
PKCS7_SIGNER_INFO *PKCS7_SIGNER_INFO_new()
|
||||
{
|
||||
PKCS7_SIGNER_INFO *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,PKCS7_SIGNER_INFO);
|
||||
M_ASN1_New(ret->version,ASN1_INTEGER_new);
|
||||
|
@@ -62,8 +62,8 @@
|
||||
#include "objects.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_X509_KEY,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_KEY_NEW,ASN1_R_BAD_GET_OBJECT);
|
||||
* ASN1err(ASN1_F_D2I_X509_KEY,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_KEY_NEW,ERR_R_BAD_GET_ASN1_OBJECT_CALL);
|
||||
*/
|
||||
|
||||
int i2d_X509_KEY(a,pp)
|
||||
|
@@ -158,6 +158,11 @@ X509 *x;
|
||||
(i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)) <= 0) goto err;
|
||||
|
||||
pkey=X509_get_pubkey(x);
|
||||
if (pkey == NULL)
|
||||
{
|
||||
BIO_printf(bp,"%12sUnable to load Public Key\n","");
|
||||
}
|
||||
else
|
||||
#ifndef NO_RSA
|
||||
if (pkey->type == EVP_PKEY_RSA)
|
||||
{
|
||||
@@ -175,7 +180,7 @@ X509 *x;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
BIO_printf(bp,"%12sDSA Public Key:\n","");
|
||||
BIO_printf(bp,"%12sUnknown Public Key:\n","");
|
||||
|
||||
n=X509_get_ext_count(x);
|
||||
if (n > 0)
|
||||
|
353
crypto/asn1/x
Normal file
353
crypto/asn1/x
Normal file
@@ -0,0 +1,353 @@
|
||||
/* crypto/asn1/x_crl.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "asn1_mac.h"
|
||||
#include "x509.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_X509_CRL,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_X509_CRL_INFO,ASN1_R_EXPECTING_A_SEQUENCE);
|
||||
* ASN1err(ASN1_F_D2I_X509_REVOKED,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_CRL_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_CRL_INFO_NEW,ASN1_R_EXPECTING_A_SEQUENCE);
|
||||
* ASN1err(ASN1_F_X509_REVOKED_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
#ifndef NOPROTO
|
||||
static int X509_REVOKED_cmp(X509_REVOKED **a,X509_REVOKED **b);
|
||||
static int X509_REVOKED_seq_cmp(X509_REVOKED **a,X509_REVOKED **b);
|
||||
#else
|
||||
static int X509_REVOKED_cmp();
|
||||
static int X509_REVOKED_seq_cmp();
|
||||
#endif
|
||||
|
||||
int i2d_X509_REVOKED(a,pp)
|
||||
X509_REVOKED *a;
|
||||
unsigned char **pp;
|
||||
{
|
||||
M_ASN1_I2D_vars(a);
|
||||
|
||||
M_ASN1_I2D_len(a->serialNumber,i2d_ASN1_INTEGER);
|
||||
M_ASN1_I2D_len(a->revocationDate,i2d_ASN1_UTCTIME);
|
||||
M_ASN1_I2D_len_SEQ_opt(a->extensions,i2d_X509_EXTENSION);
|
||||
|
||||
M_ASN1_I2D_seq_total();
|
||||
|
||||
M_ASN1_I2D_put(a->serialNumber,i2d_ASN1_INTEGER);
|
||||
M_ASN1_I2D_put(a->revocationDate,i2d_ASN1_UTCTIME);
|
||||
M_ASN1_I2D_put_SEQ_opt(a->extensions,i2d_X509_EXTENSION);
|
||||
|
||||
M_ASN1_I2D_finish();
|
||||
}
|
||||
|
||||
X509_REVOKED *d2i_X509_REVOKED(a,pp,length)
|
||||
X509_REVOKED **a;
|
||||
unsigned char **pp;
|
||||
long length;
|
||||
{
|
||||
M_ASN1_D2I_vars(a,X509_REVOKED *,X509_REVOKED_new);
|
||||
|
||||
M_ASN1_D2I_Init();
|
||||
M_ASN1_D2I_start_sequence();
|
||||
M_ASN1_D2I_get(ret->serialNumber,d2i_ASN1_INTEGER);
|
||||
M_ASN1_D2I_get(ret->revocationDate,d2i_ASN1_UTCTIME);
|
||||
M_ASN1_D2I_get_seq_opt(ret->extensions,d2i_X509_EXTENSION);
|
||||
M_ASN1_D2I_Finish(a,X509_REVOKED_free,ASN1_F_D2I_X509_REVOKED);
|
||||
}
|
||||
|
||||
int i2d_X509_CRL_INFO(a,pp)
|
||||
X509_CRL_INFO *a;
|
||||
unsigned char **pp;
|
||||
{
|
||||
int v1=0;
|
||||
long l=0;
|
||||
M_ASN1_I2D_vars(a);
|
||||
|
||||
if (sk_num(a->revoked) != 0)
|
||||
qsort((char *)a->revoked->data,sk_num(a->revoked),
|
||||
sizeof(X509_REVOKED *),(int (*)(P_CC_CC))X509_REVOKED_seq_cmp);
|
||||
if ((a->version != NULL) && ((l=ASN1_INTEGER_get(a->version)) != 0))
|
||||
{
|
||||
M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
|
||||
}
|
||||
M_ASN1_I2D_len(a->sig_alg,i2d_X509_ALGOR);
|
||||
M_ASN1_I2D_len(a->issuer,i2d_X509_NAME);
|
||||
M_ASN1_I2D_len(a->lastUpdate,i2d_ASN1_UTCTIME);
|
||||
if (a->nextUpdate != NULL)
|
||||
{ M_ASN1_I2D_len(a->nextUpdate,i2d_ASN1_UTCTIME); }
|
||||
M_ASN1_I2D_len_SEQ_opt(a->revoked,i2d_X509_REVOKED);
|
||||
M_ASN1_I2D_len_EXP_set_opt(a->extensions,i2d_X509_EXTENSION,0,
|
||||
V_ASN1_SEQUENCE,v1);
|
||||
|
||||
M_ASN1_I2D_seq_total();
|
||||
|
||||
if ((a->version != NULL) && (l != 0))
|
||||
{
|
||||
M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER);
|
||||
}
|
||||
M_ASN1_I2D_put(a->sig_alg,i2d_X509_ALGOR);
|
||||
M_ASN1_I2D_put(a->issuer,i2d_X509_NAME);
|
||||
M_ASN1_I2D_put(a->lastUpdate,i2d_ASN1_UTCTIME);
|
||||
if (a->nextUpdate != NULL)
|
||||
{ M_ASN1_I2D_put(a->nextUpdate,i2d_ASN1_UTCTIME); }
|
||||
M_ASN1_I2D_put_SEQ_opt(a->revoked,i2d_X509_REVOKED);
|
||||
M_ASN1_I2D_put_EXP_set_opt(a->extensions,i2d_X509_EXTENSION,0,
|
||||
V_ASN1_SEQUENCE,v1);
|
||||
|
||||
M_ASN1_I2D_finish();
|
||||
}
|
||||
|
||||
X509_CRL_INFO *d2i_X509_CRL_INFO(a,pp,length)
|
||||
X509_CRL_INFO **a;
|
||||
unsigned char **pp;
|
||||
long length;
|
||||
{
|
||||
int i,ver=0;
|
||||
M_ASN1_D2I_vars(a,X509_CRL_INFO *,X509_CRL_INFO_new);
|
||||
|
||||
|
||||
M_ASN1_D2I_Init();
|
||||
M_ASN1_D2I_start_sequence();
|
||||
M_ASN1_D2I_get_opt(ret->version,d2i_ASN1_INTEGER,V_ASN1_INTEGER);
|
||||
if (ret->version != NULL)
|
||||
ver=ret->version->data[0];
|
||||
|
||||
if ((ver == 0) && (ret->version != NULL))
|
||||
{
|
||||
ASN1_INTEGER_free(ret->version);
|
||||
ret->version=NULL;
|
||||
}
|
||||
M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
|
||||
M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME);
|
||||
M_ASN1_D2I_get(ret->lastUpdate,d2i_ASN1_UTCTIME);
|
||||
M_ASN1_D2I_get_opt(ret->nextUpdate,d2i_ASN1_UTCTIME,V_ASN1_UTCTIME);
|
||||
if (ret->revoked != NULL)
|
||||
{
|
||||
while (sk_num(ret->revoked))
|
||||
X509_REVOKED_free((X509_REVOKED *)sk_pop(ret->revoked));
|
||||
}
|
||||
M_ASN1_D2I_get_seq_opt(ret->revoked,d2i_X509_REVOKED);
|
||||
|
||||
if (ret->revoked != NULL)
|
||||
{
|
||||
for (i=0; i<sk_num(ret->revoked); i++)
|
||||
{
|
||||
((X509_REVOKED *)sk_value(ret->revoked,i))->sequence=i;
|
||||
}
|
||||
}
|
||||
|
||||
if (ver >= 1)
|
||||
{
|
||||
if (ret->extensions != NULL)
|
||||
{
|
||||
while (sk_num(ret->extensions))
|
||||
X509_EXTENSION_free((X509_EXTENSION *)
|
||||
sk_pop(ret->extensions));
|
||||
}
|
||||
|
||||
M_ASN1_D2I_get_EXP_set_opt(ret->extensions,d2i_X509_EXTENSION,
|
||||
0,V_ASN1_SEQUENCE);
|
||||
}
|
||||
|
||||
M_ASN1_D2I_Finish(a,X509_CRL_INFO_free,ASN1_F_D2I_X509_CRL_INFO);
|
||||
}
|
||||
|
||||
int i2d_X509_CRL(a,pp)
|
||||
X509_CRL *a;
|
||||
unsigned char **pp;
|
||||
{
|
||||
M_ASN1_I2D_vars(a);
|
||||
|
||||
M_ASN1_I2D_len(a->crl,i2d_X509_CRL_INFO);
|
||||
M_ASN1_I2D_len(a->sig_alg,i2d_X509_ALGOR);
|
||||
M_ASN1_I2D_len(a->signature,i2d_ASN1_BIT_STRING);
|
||||
|
||||
M_ASN1_I2D_seq_total();
|
||||
|
||||
M_ASN1_I2D_put(a->crl,i2d_X509_CRL_INFO);
|
||||
M_ASN1_I2D_put(a->sig_alg,i2d_X509_ALGOR);
|
||||
M_ASN1_I2D_put(a->signature,i2d_ASN1_BIT_STRING);
|
||||
|
||||
M_ASN1_I2D_finish();
|
||||
}
|
||||
|
||||
X509_CRL *d2i_X509_CRL(a,pp,length)
|
||||
X509_CRL **a;
|
||||
unsigned char **pp;
|
||||
long length;
|
||||
{
|
||||
M_ASN1_D2I_vars(a,X509_CRL *,X509_CRL_new);
|
||||
|
||||
M_ASN1_D2I_Init();
|
||||
M_ASN1_D2I_start_sequence();
|
||||
M_ASN1_D2I_get(ret->crl,d2i_X509_CRL_INFO);
|
||||
M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
|
||||
M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
|
||||
|
||||
M_ASN1_D2I_Finish(a,X509_CRL_free,ASN1_F_D2I_X509_CRL);
|
||||
}
|
||||
|
||||
|
||||
X509_REVOKED *X509_REVOKED_new()
|
||||
{
|
||||
X509_REVOKED *ret=NULL;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_REVOKED);
|
||||
M_ASN1_New(ret->serialNumber,ASN1_INTEGER_new);
|
||||
M_ASN1_New(ret->revocationDate,ASN1_UTCTIME_new);
|
||||
ret->extensions=NULL;
|
||||
return(ret);
|
||||
M_ASN1_New_Error(ASN1_F_X509_REVOKED_NEW);
|
||||
}
|
||||
|
||||
X509_CRL_INFO *X509_CRL_INFO_new()
|
||||
{
|
||||
X509_CRL_INFO *ret=NULL;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_CRL_INFO);
|
||||
ret->version=NULL;
|
||||
M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
|
||||
M_ASN1_New(ret->issuer,X509_NAME_new);
|
||||
M_ASN1_New(ret->lastUpdate,ASN1_UTCTIME_new);
|
||||
ret->nextUpdate=NULL;
|
||||
M_ASN1_New(ret->revoked,sk_new_null);
|
||||
M_ASN1_New(ret->extensions,sk_new_null);
|
||||
ret->revoked->comp=(int (*)())X509_REVOKED_cmp;
|
||||
return(ret);
|
||||
M_ASN1_New_Error(ASN1_F_X509_CRL_INFO_NEW);
|
||||
}
|
||||
|
||||
X509_CRL *X509_CRL_new()
|
||||
{
|
||||
X509_CRL *ret=NULL;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_CRL);
|
||||
ret->references=1;
|
||||
M_ASN1_New(ret->crl,X509_CRL_INFO_new);
|
||||
M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
|
||||
M_ASN1_New(ret->signature,ASN1_BIT_STRING_new);
|
||||
return(ret);
|
||||
M_ASN1_New_Error(ASN1_F_X509_CRL_NEW);
|
||||
}
|
||||
|
||||
void X509_REVOKED_free(a)
|
||||
X509_REVOKED *a;
|
||||
{
|
||||
if (a == NULL) return;
|
||||
ASN1_INTEGER_free(a->serialNumber);
|
||||
ASN1_UTCTIME_free(a->revocationDate);
|
||||
sk_pop_free(a->extensions,X509_EXTENSION_free);
|
||||
Free((char *)a);
|
||||
}
|
||||
|
||||
void X509_CRL_INFO_free(a)
|
||||
X509_CRL_INFO *a;
|
||||
{
|
||||
if (a == NULL) return;
|
||||
ASN1_INTEGER_free(a->version);
|
||||
X509_ALGOR_free(a->sig_alg);
|
||||
X509_NAME_free(a->issuer);
|
||||
ASN1_UTCTIME_free(a->lastUpdate);
|
||||
if (a->nextUpdate)
|
||||
ASN1_UTCTIME_free(a->nextUpdate);
|
||||
sk_pop_free(a->revoked,X509_REVOKED_free);
|
||||
sk_pop_free(a->extensions,X509_EXTENSION_free);
|
||||
Free((char *)a);
|
||||
}
|
||||
|
||||
void X509_CRL_free(a)
|
||||
X509_CRL *a;
|
||||
{
|
||||
int i;
|
||||
|
||||
if (a == NULL) return;
|
||||
|
||||
i=CRYPTO_add(&a->references,-1,CRYPTO_LOCK_X509_CRL);
|
||||
#ifdef REF_PRINT
|
||||
REF_PRINT("X509_CRL",a);
|
||||
#endif
|
||||
if (i > 0) return;
|
||||
#ifdef REF_CHECK
|
||||
if (i < 0)
|
||||
{
|
||||
fprintf(stderr,"X509_CRL_free, bad reference count\n");
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
X509_CRL_INFO_free(a->crl);
|
||||
X509_ALGOR_free(a->sig_alg);
|
||||
ASN1_BIT_STRING_free(a->signature);
|
||||
Free((char *)a);
|
||||
}
|
||||
|
||||
static int X509_REVOKED_cmp(a,b)
|
||||
X509_REVOKED **a,**b;
|
||||
{
|
||||
return(ASN1_STRING_cmp(
|
||||
(ASN1_STRING *)(*a)->serialNumber,
|
||||
(ASN1_STRING *)(*b)->serialNumber));
|
||||
}
|
||||
|
||||
static int X509_REVOKED_seq_cmp(a,b)
|
||||
X509_REVOKED **a,**b;
|
||||
{
|
||||
return((*a)->sequence-(*b)->sequence);
|
||||
}
|
@@ -61,9 +61,9 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_X509_ALGOR,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_ALGOR_NEW,ASN1_R_EXPECTING_A_SEQUENCE);
|
||||
* ASN1err(ASN1_F_D2I_X509_ALGOR,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_X509_ALGOR,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_ALGOR_NEW,ERR_R_EXPECTING_AN_ASN1_SEQUENCE);
|
||||
* ASN1err(ASN1_F_D2I_X509_ALGOR,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_X509_ALGOR(a,pp)
|
||||
@@ -107,9 +107,10 @@ long length;
|
||||
X509_ALGOR *X509_ALGOR_new()
|
||||
{
|
||||
X509_ALGOR *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_ALGOR);
|
||||
M_ASN1_New(ret->algorithm,ASN1_OBJECT_new);
|
||||
ret->algorithm=OBJ_nid2obj(NID_undef);
|
||||
ret->parameter=NULL;
|
||||
return(ret);
|
||||
M_ASN1_New_Error(ASN1_F_X509_ALGOR_NEW);
|
||||
|
@@ -62,7 +62,7 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_X509_ATTRIBUTE,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_X509_ATTRIBUTE,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_ATTRIBUTE_NEW,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
|
||||
* ASN1err(ASN1_F_I2D_X509_ATTRIBUTE,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
|
||||
*/
|
||||
@@ -115,7 +115,7 @@ long length;
|
||||
(M_ASN1_next == (V_ASN1_CONSTRUCTED|V_ASN1_UNIVERSAL|V_ASN1_SET)))
|
||||
{
|
||||
ret->set=1;
|
||||
M_ASN1_D2I_get_set(ret->value.set,d2i_ASN1_TYPE);
|
||||
M_ASN1_D2I_get_set(ret->value.set,d2i_ASN1_TYPE,ASN1_TYPE_free);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -126,12 +126,37 @@ long length;
|
||||
M_ASN1_D2I_Finish(a,X509_ATTRIBUTE_free,ASN1_F_D2I_X509_ATTRIBUTE);
|
||||
}
|
||||
|
||||
X509_ATTRIBUTE *X509_ATTRIBUTE_create(nid,atrtype,value)
|
||||
int nid;
|
||||
int atrtype;
|
||||
char *value;
|
||||
{
|
||||
X509_ATTRIBUTE *ret=NULL;
|
||||
ASN1_TYPE *val=NULL;
|
||||
|
||||
if ((ret=X509_ATTRIBUTE_new()) == NULL)
|
||||
return(NULL);
|
||||
ret->object=OBJ_nid2obj(nid);
|
||||
ret->set=1;
|
||||
if ((ret->value.set=sk_new_null()) == NULL) goto err;
|
||||
if ((val=ASN1_TYPE_new()) == NULL) goto err;
|
||||
if (!sk_push(ret->value.set,(char *)val)) goto err;
|
||||
|
||||
ASN1_TYPE_set(val,atrtype,value);
|
||||
return(ret);
|
||||
err:
|
||||
if (ret != NULL) X509_ATTRIBUTE_free(ret);
|
||||
if (val != NULL) ASN1_TYPE_free(val);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
X509_ATTRIBUTE *X509_ATTRIBUTE_new()
|
||||
{
|
||||
X509_ATTRIBUTE *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_ATTRIBUTE);
|
||||
M_ASN1_New(ret->object,ASN1_OBJECT_new);
|
||||
ret->object=OBJ_nid2obj(NID_undef);
|
||||
ret->set=0;
|
||||
ret->value.ptr=NULL;
|
||||
return(ret);
|
||||
|
@@ -61,8 +61,8 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_X509_CINF,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_CINF_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_X509_CINF,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_CINF_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_X509_CINF(a,pp)
|
||||
@@ -140,7 +140,7 @@ long length;
|
||||
if (ret->subjectUID != NULL)
|
||||
{
|
||||
ASN1_BIT_STRING_free(ret->subjectUID);
|
||||
ret->issuerUID=NULL;
|
||||
ret->subjectUID=NULL;
|
||||
}
|
||||
M_ASN1_D2I_get_IMP_opt(ret->issuerUID,d2i_ASN1_BIT_STRING, 1,
|
||||
V_ASN1_BIT_STRING);
|
||||
@@ -153,8 +153,8 @@ long length;
|
||||
while (sk_num(ret->extensions))
|
||||
X509_EXTENSION_free((X509_EXTENSION *)
|
||||
sk_pop(ret->extensions));
|
||||
M_ASN1_D2I_get_EXP_set_opt(ret->extensions,d2i_X509_EXTENSION,3,
|
||||
V_ASN1_SEQUENCE);
|
||||
M_ASN1_D2I_get_EXP_set_opt(ret->extensions,d2i_X509_EXTENSION,
|
||||
X509_EXTENSION_free,3,V_ASN1_SEQUENCE);
|
||||
}
|
||||
M_ASN1_D2I_Finish(a,X509_CINF_free,ASN1_F_D2I_X509_CINF);
|
||||
}
|
||||
@@ -162,6 +162,7 @@ long length;
|
||||
X509_CINF *X509_CINF_new()
|
||||
{
|
||||
X509_CINF *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_CINF);
|
||||
ret->version=NULL;
|
||||
|
@@ -62,12 +62,12 @@
|
||||
#include "x509.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_X509_CRL,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_X509_CRL_INFO,ASN1_R_EXPECTING_A_SEQUENCE);
|
||||
* ASN1err(ASN1_F_D2I_X509_REVOKED,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_CRL_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_CRL_INFO_NEW,ASN1_R_EXPECTING_A_SEQUENCE);
|
||||
* ASN1err(ASN1_F_X509_REVOKED_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_X509_CRL,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_X509_CRL_INFO,ERR_R_EXPECTING_AN_ASN1_SEQUENCE);
|
||||
* ASN1err(ASN1_F_D2I_X509_REVOKED,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_CRL_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_CRL_INFO_NEW,ERR_R_EXPECTING_AN_ASN1_SEQUENCE);
|
||||
* ASN1err(ASN1_F_X509_REVOKED_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
#ifndef NOPROTO
|
||||
@@ -108,7 +108,8 @@ long length;
|
||||
M_ASN1_D2I_start_sequence();
|
||||
M_ASN1_D2I_get(ret->serialNumber,d2i_ASN1_INTEGER);
|
||||
M_ASN1_D2I_get(ret->revocationDate,d2i_ASN1_UTCTIME);
|
||||
M_ASN1_D2I_get_seq_opt(ret->extensions,d2i_X509_EXTENSION);
|
||||
M_ASN1_D2I_get_seq_opt(ret->extensions,d2i_X509_EXTENSION,
|
||||
X509_EXTENSION_free);
|
||||
M_ASN1_D2I_Finish(a,X509_REVOKED_free,ASN1_F_D2I_X509_REVOKED);
|
||||
}
|
||||
|
||||
@@ -183,7 +184,7 @@ long length;
|
||||
while (sk_num(ret->revoked))
|
||||
X509_REVOKED_free((X509_REVOKED *)sk_pop(ret->revoked));
|
||||
}
|
||||
M_ASN1_D2I_get_seq_opt(ret->revoked,d2i_X509_REVOKED);
|
||||
M_ASN1_D2I_get_seq_opt(ret->revoked,d2i_X509_REVOKED,X509_REVOKED_free);
|
||||
|
||||
if (ret->revoked != NULL)
|
||||
{
|
||||
@@ -203,7 +204,7 @@ long length;
|
||||
}
|
||||
|
||||
M_ASN1_D2I_get_EXP_set_opt(ret->extensions,d2i_X509_EXTENSION,
|
||||
0,V_ASN1_SEQUENCE);
|
||||
X509_EXTENSION_free,0,V_ASN1_SEQUENCE);
|
||||
}
|
||||
|
||||
M_ASN1_D2I_Finish(a,X509_CRL_INFO_free,ASN1_F_D2I_X509_CRL_INFO);
|
||||
@@ -248,6 +249,7 @@ long length;
|
||||
X509_REVOKED *X509_REVOKED_new()
|
||||
{
|
||||
X509_REVOKED *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_REVOKED);
|
||||
M_ASN1_New(ret->serialNumber,ASN1_INTEGER_new);
|
||||
@@ -260,6 +262,7 @@ X509_REVOKED *X509_REVOKED_new()
|
||||
X509_CRL_INFO *X509_CRL_INFO_new()
|
||||
{
|
||||
X509_CRL_INFO *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_CRL_INFO);
|
||||
ret->version=NULL;
|
||||
@@ -277,6 +280,7 @@ X509_CRL_INFO *X509_CRL_INFO_new()
|
||||
X509_CRL *X509_CRL_new()
|
||||
{
|
||||
X509_CRL *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_CRL);
|
||||
ret->references=1;
|
||||
|
@@ -62,8 +62,8 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_X509_EXTENSION,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_EXTENSION_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_X509_EXTENSION,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_EXTENSION_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_X509_EXTENSION(a,pp)
|
||||
@@ -130,9 +130,10 @@ long length;
|
||||
X509_EXTENSION *X509_EXTENSION_new()
|
||||
{
|
||||
X509_EXTENSION *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_EXTENSION);
|
||||
M_ASN1_New(ret->object,ASN1_OBJECT_new);
|
||||
ret->object=OBJ_nid2obj(NID_undef);
|
||||
M_ASN1_New(ret->value,ASN1_OCTET_STRING_new);
|
||||
ret->critical=0;
|
||||
ret->netscape_hack=0;
|
||||
|
@@ -62,9 +62,9 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_X509_NAME,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_X509_NAME,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_NAME_NEW,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
|
||||
* ASN1err(ASN1_F_D2I_X509_NAME_ENTRY,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_X509_NAME_ENTRY,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_NAME_ENTRY_NEW,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
|
||||
*/
|
||||
|
||||
@@ -213,7 +213,8 @@ long length;
|
||||
for (;;)
|
||||
{
|
||||
if (M_ASN1_D2I_end_sequence()) break;
|
||||
M_ASN1_D2I_get_set(ret->entries,d2i_X509_NAME_ENTRY);
|
||||
M_ASN1_D2I_get_set(ret->entries,d2i_X509_NAME_ENTRY,
|
||||
X509_NAME_ENTRY_free);
|
||||
for (; idx < sk_num(ret->entries); idx++)
|
||||
{
|
||||
((X509_NAME_ENTRY *)sk_value(ret->entries,idx))->set=
|
||||
@@ -234,9 +235,11 @@ long length;
|
||||
X509_NAME *X509_NAME_new()
|
||||
{
|
||||
X509_NAME *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_NAME);
|
||||
if ((ret->entries=sk_new(NULL)) == NULL) goto err2;
|
||||
if ((ret->entries=sk_new(NULL)) == NULL)
|
||||
{ c.line=__LINE__; goto err2; }
|
||||
M_ASN1_New(ret->bytes,BUF_MEM_new);
|
||||
ret->modified=1;
|
||||
return(ret);
|
||||
@@ -246,6 +249,7 @@ X509_NAME *X509_NAME_new()
|
||||
X509_NAME_ENTRY *X509_NAME_ENTRY_new()
|
||||
{
|
||||
X509_NAME_ENTRY *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_NAME_ENTRY);
|
||||
/* M_ASN1_New(ret->object,ASN1_OBJECT_new);*/
|
||||
|
@@ -91,6 +91,7 @@ long length;
|
||||
if (ret->cipher.cipher == NULL)
|
||||
{
|
||||
c.error=ASN1_R_UNSUPPORTED_CIPHER;
|
||||
c.line=__LINE__;
|
||||
goto err;
|
||||
}
|
||||
if (ret->enc_algor->parameter->type == V_ASN1_OCTET_STRING)
|
||||
@@ -99,6 +100,7 @@ long length;
|
||||
if (i > EVP_MAX_IV_LENGTH)
|
||||
{
|
||||
c.error=ASN1_R_IV_TOO_LARGE;
|
||||
c.line=__LINE__;
|
||||
goto err;
|
||||
}
|
||||
memcpy(ret->cipher.iv,
|
||||
@@ -112,6 +114,7 @@ long length;
|
||||
X509_PKEY *X509_PKEY_new()
|
||||
{
|
||||
X509_PKEY *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_PKEY);
|
||||
ret->version=0;
|
||||
|
@@ -61,8 +61,8 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_X509_PUBKEY,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_PUBKEY_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_X509_PUBKEY,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_PUBKEY_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_X509_PUBKEY(a,pp)
|
||||
@@ -104,6 +104,7 @@ long length;
|
||||
X509_PUBKEY *X509_PUBKEY_new()
|
||||
{
|
||||
X509_PUBKEY *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_PUBKEY);
|
||||
M_ASN1_New(ret->algor,X509_ALGOR_new);
|
||||
|
@@ -62,10 +62,10 @@
|
||||
#include "x509.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_X509_REQ,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_X509_REQ_INFO,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_REQ_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_REQ_INFO_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_X509_REQ,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_X509_REQ_INFO,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_REQ_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_REQ_INFO_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_X509_REQ_INFO(a,pp)
|
||||
@@ -141,7 +141,8 @@ long length;
|
||||
ret->req_kludge=1;
|
||||
else
|
||||
{
|
||||
M_ASN1_D2I_get_IMP_set(ret->attributes,d2i_X509_ATTRIBUTE,0);
|
||||
M_ASN1_D2I_get_IMP_set(ret->attributes,d2i_X509_ATTRIBUTE,
|
||||
X509_ATTRIBUTE_free,0);
|
||||
}
|
||||
|
||||
M_ASN1_D2I_Finish(a,X509_REQ_INFO_free,ASN1_F_D2I_X509_REQ_INFO);
|
||||
@@ -150,6 +151,7 @@ long length;
|
||||
X509_REQ_INFO *X509_REQ_INFO_new()
|
||||
{
|
||||
X509_REQ_INFO *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_REQ_INFO);
|
||||
M_ASN1_New(ret->version,ASN1_INTEGER_new);
|
||||
@@ -208,6 +210,7 @@ long length;
|
||||
X509_REQ *X509_REQ_new()
|
||||
{
|
||||
X509_REQ *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_REQ);
|
||||
ret->references=1;
|
||||
|
@@ -61,8 +61,8 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_X509_SIG,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_SIG_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_X509_SIG,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_SIG_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_X509_SIG(a,pp)
|
||||
@@ -99,6 +99,7 @@ long length;
|
||||
X509_SIG *X509_SIG_new()
|
||||
{
|
||||
X509_SIG *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_SIG);
|
||||
M_ASN1_New(ret->algor,X509_ALGOR_new);
|
||||
|
@@ -66,10 +66,10 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_NETSCAPE_SPKAC,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_NETSCAPE_SPKAC_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_NETSCAPE_SPKI,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_NETSCAPE_SPKI_NEW,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_NETSCAPE_SPKAC,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_NETSCAPE_SPKAC_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_D2I_NETSCAPE_SPKI,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_NETSCAPE_SPKI_NEW,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
*/
|
||||
|
||||
int i2d_NETSCAPE_SPKAC(a,pp)
|
||||
@@ -106,6 +106,7 @@ long length;
|
||||
NETSCAPE_SPKAC *NETSCAPE_SPKAC_new()
|
||||
{
|
||||
NETSCAPE_SPKAC *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,NETSCAPE_SPKAC);
|
||||
M_ASN1_New(ret->pubkey,X509_PUBKEY_new);
|
||||
@@ -160,6 +161,7 @@ long length;
|
||||
NETSCAPE_SPKI *NETSCAPE_SPKI_new()
|
||||
{
|
||||
NETSCAPE_SPKI *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,NETSCAPE_SPKI);
|
||||
M_ASN1_New(ret->spkac,NETSCAPE_SPKAC_new);
|
||||
|
@@ -99,6 +99,7 @@ long length;
|
||||
X509_VAL *X509_VAL_new()
|
||||
{
|
||||
X509_VAL *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_VAL);
|
||||
M_ASN1_New(ret->notBefore,ASN1_UTCTIME_new);
|
||||
|
@@ -62,8 +62,8 @@
|
||||
#include "asn1_mac.h"
|
||||
|
||||
/*
|
||||
* ASN1err(ASN1_F_D2I_X509,ASN1_R_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_NEW,ASN1_R_BAD_GET_OBJECT);
|
||||
* ASN1err(ASN1_F_D2I_X509,ERR_R_ASN1_LENGTH_MISMATCH);
|
||||
* ASN1err(ASN1_F_X509_NEW,ERR_R_BAD_GET_ASN1_OBJECT_CALL);
|
||||
*/
|
||||
|
||||
static ASN1_METHOD meth={
|
||||
@@ -117,6 +117,7 @@ ret->name=X509_NAME_oneline(ret->cert_info->subject,NULL,0);
|
||||
X509 *X509_new()
|
||||
{
|
||||
X509 *ret=NULL;
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509);
|
||||
ret->references=1;
|
||||
@@ -149,9 +150,11 @@ X509 *a;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* CRYPTO_free_ex_data(bio_meth,(char *)a,&a->ex_data); */
|
||||
X509_CINF_free(a->cert_info);
|
||||
X509_ALGOR_free(a->sig_alg);
|
||||
ASN1_BIT_STRING_free(a->signature);
|
||||
|
||||
if (a->name != NULL) Free(a->name);
|
||||
Free((char *)a);
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ asm/bx86-out.o: asm/bx86unix.cpp
|
||||
|
||||
# bsdi
|
||||
asm/bx86bsdi.o: asm/bx86unix.cpp
|
||||
$(CPP) -DBSDI asm/bx86unix.cpp | as -o asm/bx86bsdi.o
|
||||
$(CPP) -DBSDI asm/bx86unix.cpp | sed 's/ :/:/' | as -o asm/bx86bsdi.o
|
||||
|
||||
asm/bx86unix.cpp:
|
||||
(cd asm; perl bf-586.pl cpp >bx86unix.cpp)
|
||||
|
@@ -64,7 +64,7 @@
|
||||
* CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993)
|
||||
*/
|
||||
|
||||
char *BF_version="BlowFish part of SSLeay 0.9.0b 29-Jun-1998";
|
||||
char *BF_version="BlowFish part of SSLeay 0.9.1a 06-Jul-1998";
|
||||
|
||||
char *BF_options()
|
||||
{
|
||||
|
@@ -92,7 +92,8 @@ struct tms {
|
||||
#include <sys/timeb.h>
|
||||
#endif
|
||||
|
||||
#ifdef sun
|
||||
#if defined(sun) || defined(__ultrix)
|
||||
#define _POSIX_SOURCE
|
||||
#include <limits.h>
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
@@ -92,7 +92,8 @@ struct tms {
|
||||
#include <sys/timeb.h>
|
||||
#endif
|
||||
|
||||
#ifdef sun
|
||||
#if defined(sun) || defined(__ultrix)
|
||||
#define _POSIX_SOURCE
|
||||
#include <limits.h>
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
@@ -148,7 +148,7 @@ unsigned char *ip;
|
||||
|
||||
int BIO_get_port(str,port_ptr)
|
||||
char *str;
|
||||
short *port_ptr;
|
||||
unsigned short *port_ptr;
|
||||
{
|
||||
int i;
|
||||
struct servent *s;
|
||||
@@ -223,13 +223,13 @@ char *parg;
|
||||
{
|
||||
case BIO_GHBN_CTRL_HITS:
|
||||
return(BIO_ghbn_hits);
|
||||
break;
|
||||
/* break; */
|
||||
case BIO_GHBN_CTRL_MISSES:
|
||||
return(BIO_ghbn_miss);
|
||||
break;
|
||||
/* break; */
|
||||
case BIO_GHBN_CTRL_CACHE_SIZE:
|
||||
return(GHBN_NUM);
|
||||
break;
|
||||
/* break; */
|
||||
case BIO_GHBN_CTRL_GET_ENTRY:
|
||||
if ((iarg >= 0) && (iarg <GHBN_NUM) &&
|
||||
(ghbn_cache[iarg].order > 0))
|
||||
@@ -241,7 +241,7 @@ char *parg;
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
break;
|
||||
/* break; */
|
||||
case BIO_GHBN_CTRL_FLUSH:
|
||||
for (i=0; i<GHBN_NUM; i++)
|
||||
ghbn_cache[i].order=0;
|
||||
@@ -258,46 +258,51 @@ struct hostent *a;
|
||||
struct hostent *ret;
|
||||
int i,j;
|
||||
|
||||
ret=(struct hostent *)malloc(sizeof(struct hostent));
|
||||
MemCheck_off();
|
||||
ret=(struct hostent *)Malloc(sizeof(struct hostent));
|
||||
if (ret == NULL) return(NULL);
|
||||
memset(ret,0,sizeof(struct hostent));
|
||||
|
||||
for (i=0; a->h_aliases[i] != NULL; i++)
|
||||
;
|
||||
i++;
|
||||
ret->h_aliases=(char **)malloc(sizeof(char *)*i);
|
||||
ret->h_aliases=(char **)Malloc(sizeof(char *)*i);
|
||||
memset(ret->h_aliases,0,sizeof(char *)*i);
|
||||
if (ret == NULL) goto err;
|
||||
|
||||
for (i=0; a->h_addr_list[i] != NULL; i++)
|
||||
;
|
||||
i++;
|
||||
ret->h_addr_list=(char **)malloc(sizeof(char *)*i);
|
||||
ret->h_addr_list=(char **)Malloc(sizeof(char *)*i);
|
||||
memset(ret->h_addr_list,0,sizeof(char *)*i);
|
||||
if (ret->h_addr_list == NULL) goto err;
|
||||
|
||||
j=strlen(a->h_name)+1;
|
||||
if ((ret->h_name=malloc(j)) == NULL) goto err;
|
||||
memcpy((char *)ret->h_name,a->h_name,j);
|
||||
if ((ret->h_name=Malloc(j)) == NULL) goto err;
|
||||
memcpy((char *)ret->h_name,a->h_name,j+1);
|
||||
for (i=0; a->h_aliases[i] != NULL; i++)
|
||||
{
|
||||
j=strlen(a->h_aliases[i])+1;
|
||||
if ((ret->h_aliases[i]=malloc(j)) == NULL) goto err;
|
||||
memcpy(ret->h_aliases[i],a->h_aliases[i],j);
|
||||
if ((ret->h_aliases[i]=Malloc(j)) == NULL) goto err;
|
||||
memcpy(ret->h_aliases[i],a->h_aliases[i],j+1);
|
||||
}
|
||||
ret->h_length=a->h_length;
|
||||
ret->h_addrtype=a->h_addrtype;
|
||||
for (i=0; a->h_addr_list[i] != NULL; i++)
|
||||
{
|
||||
if ((ret->h_addr_list[i]=malloc(a->h_length)) == NULL)
|
||||
if ((ret->h_addr_list[i]=Malloc(a->h_length)) == NULL)
|
||||
goto err;
|
||||
memcpy(ret->h_addr_list[i],a->h_addr_list[i],a->h_length);
|
||||
}
|
||||
return(ret);
|
||||
if (0)
|
||||
{
|
||||
err:
|
||||
if (ret != NULL)
|
||||
ghbn_free(ret);
|
||||
return(NULL);
|
||||
if (ret != NULL)
|
||||
ghbn_free(ret);
|
||||
ret=NULL;
|
||||
}
|
||||
MemCheck_on();
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static void ghbn_free(a)
|
||||
@@ -308,17 +313,17 @@ struct hostent *a;
|
||||
if (a->h_aliases != NULL)
|
||||
{
|
||||
for (i=0; a->h_aliases[i] != NULL; i++)
|
||||
free(a->h_aliases[i]);
|
||||
free(a->h_aliases);
|
||||
Free(a->h_aliases[i]);
|
||||
Free(a->h_aliases);
|
||||
}
|
||||
if (a->h_addr_list != NULL)
|
||||
{
|
||||
for (i=0; a->h_addr_list[i] != NULL; i++)
|
||||
free(a->h_addr_list[i]);
|
||||
free(a->h_addr_list);
|
||||
Free(a->h_addr_list[i]);
|
||||
Free(a->h_addr_list);
|
||||
}
|
||||
if (a->h_name != NULL) free((char *)a->h_name);
|
||||
free(a);
|
||||
if (a->h_name != NULL) Free((char *)a->h_name);
|
||||
Free(a);
|
||||
}
|
||||
|
||||
struct hostent *BIO_gethostbyname(name)
|
||||
@@ -467,16 +472,18 @@ unsigned char ip[4];
|
||||
return(1);
|
||||
}
|
||||
|
||||
int BIO_get_accept_socket(host)
|
||||
int BIO_get_accept_socket(host,bind_mode)
|
||||
char *host;
|
||||
int bind_mode;
|
||||
{
|
||||
int ret=0;
|
||||
struct sockaddr_in server;
|
||||
int s= -1;
|
||||
struct sockaddr_in server,client;
|
||||
int s= -1,cs;
|
||||
unsigned char ip[4];
|
||||
short port;
|
||||
char *str,*h,*p,*e;
|
||||
unsigned long l;
|
||||
int err_num;
|
||||
|
||||
if (!BIO_sock_init()) return(INVALID_SOCKET);
|
||||
|
||||
@@ -517,12 +524,13 @@ char *host;
|
||||
if (!BIO_get_host_ip(h,&(ip[0]))) return(INVALID_SOCKET);
|
||||
l=(unsigned long)
|
||||
((unsigned long)ip[0]<<24L)|
|
||||
((unsigned long)ip[0]<<16L)|
|
||||
((unsigned long)ip[0]<< 8L)|
|
||||
((unsigned long)ip[0]);
|
||||
((unsigned long)ip[1]<<16L)|
|
||||
((unsigned long)ip[2]<< 8L)|
|
||||
((unsigned long)ip[3]);
|
||||
server.sin_addr.s_addr=htonl(l);
|
||||
}
|
||||
|
||||
again:
|
||||
s=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL);
|
||||
if (s == INVALID_SOCKET)
|
||||
{
|
||||
@@ -531,9 +539,45 @@ char *host;
|
||||
BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET,BIO_R_UNABLE_TO_CREATE_SOCKET);
|
||||
goto err;
|
||||
}
|
||||
|
||||
#ifdef SO_REUSEADDR
|
||||
if (bind_mode == BIO_BIND_REUSEADDR)
|
||||
{
|
||||
int i=1;
|
||||
|
||||
ret=setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&i,sizeof(i));
|
||||
bind_mode=BIO_BIND_NORMAL;
|
||||
}
|
||||
#endif
|
||||
if (bind(s,(struct sockaddr *)&server,sizeof(server)) == -1)
|
||||
{
|
||||
SYSerr(SYS_F_BIND,get_last_socket_error());
|
||||
#ifdef SO_REUSEADDR
|
||||
err_num=get_last_socket_error();
|
||||
if ((bind_mode == BIO_BIND_REUSEADDR_IF_UNUSED) &&
|
||||
(err_num == EADDRINUSE))
|
||||
{
|
||||
memcpy((char *)&client,(char *)&server,sizeof(server));
|
||||
if (strcmp(h,"*") == 0)
|
||||
client.sin_addr.s_addr=htonl(0x7F000001);
|
||||
cs=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL);
|
||||
if (cs != INVALID_SOCKET)
|
||||
{
|
||||
int ii;
|
||||
ii=connect(cs,(struct sockaddr *)&client,
|
||||
sizeof(client));
|
||||
closesocket(cs);
|
||||
if (ii == INVALID_SOCKET)
|
||||
{
|
||||
bind_mode=BIO_BIND_REUSEADDR;
|
||||
closesocket(s);
|
||||
goto again;
|
||||
}
|
||||
/* else error */
|
||||
}
|
||||
/* else error */
|
||||
}
|
||||
#endif
|
||||
SYSerr(SYS_F_BIND,err_num);
|
||||
ERR_add_error_data(3,"port='",host,"'");
|
||||
BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET,BIO_R_UNABLE_TO_BIND_SOCKET);
|
||||
goto err;
|
||||
@@ -550,11 +594,7 @@ err:
|
||||
if (str != NULL) Free(str);
|
||||
if ((ret == 0) && (s != INVALID_SOCKET))
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
closesocket(s);
|
||||
#else
|
||||
close(s);
|
||||
#endif
|
||||
s= INVALID_SOCKET;
|
||||
}
|
||||
return(s);
|
||||
@@ -626,3 +666,16 @@ int on;
|
||||
}
|
||||
#endif
|
||||
|
||||
int BIO_socket_nbio(s,mode)
|
||||
int s;
|
||||
int mode;
|
||||
{
|
||||
int ret= -1;
|
||||
unsigned long l;
|
||||
|
||||
l=mode;
|
||||
#ifdef FIONBIO
|
||||
ret=BIO_socket_ioctl(s,FIONBIO,&l);
|
||||
#endif
|
||||
return(ret == 0);
|
||||
}
|
||||
|
@@ -3,23 +3,25 @@
|
||||
/* Function codes. */
|
||||
#define BIO_F_ACPT_STATE 100
|
||||
#define BIO_F_BIO_ACCEPT 101
|
||||
#define BIO_F_BIO_CTRL 102
|
||||
#define BIO_F_BIO_GETS 103
|
||||
#define BIO_F_BIO_GET_ACCEPT_SOCKET 104
|
||||
#define BIO_F_BIO_GET_HOST_IP 105
|
||||
#define BIO_F_BIO_GET_PORT 106
|
||||
#define BIO_F_BIO_NEW 107
|
||||
#define BIO_F_BIO_NEW_FILE 108
|
||||
#define BIO_F_BIO_PUTS 109
|
||||
#define BIO_F_BIO_READ 110
|
||||
#define BIO_F_BIO_SOCK_INIT 111
|
||||
#define BIO_F_BIO_WRITE 112
|
||||
#define BIO_F_BUFFER_CTRL 113
|
||||
#define BIO_F_CONN_STATE 114
|
||||
#define BIO_F_FILE_CTRL 115
|
||||
#define BIO_F_MEM_WRITE 116
|
||||
#define BIO_F_SSL_NEW 117
|
||||
#define BIO_F_WSASTARTUP 118
|
||||
#define BIO_F_BIO_BER_GET_HEADER 102
|
||||
#define BIO_F_BIO_CTRL 103
|
||||
#define BIO_F_BIO_GETS 104
|
||||
#define BIO_F_BIO_GET_ACCEPT_SOCKET 105
|
||||
#define BIO_F_BIO_GET_HOST_IP 106
|
||||
#define BIO_F_BIO_GET_PORT 107
|
||||
#define BIO_F_BIO_NEW 108
|
||||
#define BIO_F_BIO_NEW_FILE 109
|
||||
#define BIO_F_BIO_PUTS 110
|
||||
#define BIO_F_BIO_READ 111
|
||||
#define BIO_F_BIO_SOCK_INIT 112
|
||||
#define BIO_F_BIO_WRITE 113
|
||||
#define BIO_F_BUFFER_CTRL 114
|
||||
#define BIO_F_CONN_STATE 115
|
||||
#define BIO_F_FILE_CTRL 116
|
||||
#define BIO_F_MEM_WRITE 117
|
||||
#define BIO_F_SOCKS4A_STATE 118
|
||||
#define BIO_F_SSL_NEW 119
|
||||
#define BIO_F_WSASTARTUP 120
|
||||
|
||||
/* Reason codes. */
|
||||
#define BIO_R_ACCEPT_ERROR 100
|
||||
@@ -38,9 +40,14 @@
|
||||
#define BIO_R_NO_PORT_DEFINED 113
|
||||
#define BIO_R_NO_PORT_SPECIFIED 114
|
||||
#define BIO_R_NULL_PARAMETER 115
|
||||
#define BIO_R_UNABLE_TO_BIND_SOCKET 116
|
||||
#define BIO_R_UNABLE_TO_CREATE_SOCKET 117
|
||||
#define BIO_R_UNABLE_TO_LISTEN_SOCKET 118
|
||||
#define BIO_R_UNINITALISED 119
|
||||
#define BIO_R_UNSUPPORTED_METHOD 120
|
||||
#define BIO_R_WSASTARTUP 121
|
||||
#define BIO_R_SOCKS_ID_AND_IDENT_DID_NOT_MATCH 116
|
||||
#define BIO_R_SOCKS_REJECTED_CONNECTION 117
|
||||
#define BIO_R_SOCKS_UNABLE_TO_TALK_TO_IDENT_SERVER 118
|
||||
#define BIO_R_SOCKS_UNKNOWN_ERROR 119
|
||||
#define BIO_R_TAG_MISMATCH 120
|
||||
#define BIO_R_UNABLE_TO_BIND_SOCKET 121
|
||||
#define BIO_R_UNABLE_TO_CREATE_SOCKET 122
|
||||
#define BIO_R_UNABLE_TO_LISTEN_SOCKET 123
|
||||
#define BIO_R_UNINITALISED 124
|
||||
#define BIO_R_UNSUPPORTED_METHOD 125
|
||||
#define BIO_R_WSASTARTUP 126
|
||||
|
@@ -84,6 +84,7 @@ extern "C" {
|
||||
#define BIO_TYPE_PROXY_SERVER (15|0x0200) /* server proxy BIO */
|
||||
#define BIO_TYPE_NBIO_TEST (16|0x0200) /* server proxy BIO */
|
||||
#define BIO_TYPE_NULL_FILTER (17|0x0200)
|
||||
#define BIO_TYPE_BER (18|0x0200) /* BER -> bin filter */
|
||||
|
||||
#define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */
|
||||
#define BIO_TYPE_FILTER 0x0200
|
||||
@@ -276,7 +277,7 @@ typedef struct bio_f_buffer_ctx_struct
|
||||
#define BIO_CONN_S_OK 6
|
||||
#define BIO_CONN_S_BLOCKED_CONNECT 7
|
||||
#define BIO_CONN_S_NBIO 8
|
||||
#define BIO_CONN_get_param_hostname BIO_ctrl
|
||||
/*#define BIO_CONN_get_param_hostname BIO_ctrl */
|
||||
|
||||
#define BIO_number_read(b) ((b)->num_read)
|
||||
#define BIO_number_written(b) ((b)->num_write)
|
||||
@@ -309,6 +310,14 @@ typedef struct bio_f_buffer_ctx_struct
|
||||
#define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125
|
||||
#define BIO_C_GET_SSL_NUM_RENEGOTIATES 126
|
||||
#define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127
|
||||
#define BIO_C_FILE_SEEK 128
|
||||
#define BIO_C_GET_CIPHER_CTX 129
|
||||
#define BIO_C_SET_BUF_MEM_EOF_RETURN 130/*return end of input value*/
|
||||
#define BIO_C_SET_BIND_MODE 131
|
||||
#define BIO_C_GET_BIND_MODE 132
|
||||
#define BIO_C_FILE_TELL 133
|
||||
#define BIO_C_GET_SOCKS 134
|
||||
#define BIO_C_SET_SOCKS 135
|
||||
|
||||
#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,(char *)arg)
|
||||
#define BIO_get_app_data(s) BIO_get_ex_data(s,0)
|
||||
@@ -320,7 +329,7 @@ void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)());
|
||||
int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(),
|
||||
int (*dup_func)(), void (*free_func)());
|
||||
|
||||
/* BIO_s_connect_socket() */
|
||||
/* BIO_s_connect() and BIO_s_socks4a_connect() */
|
||||
#define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name)
|
||||
#define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port)
|
||||
#define BIO_set_conn_ip(b,ip) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip)
|
||||
@@ -328,7 +337,8 @@ int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(),
|
||||
#define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
|
||||
#define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
|
||||
#define BIO_get_conn_ip(b,ip) BIO_ptr_ctrl(b,BIO_C_SET_CONNECT,2)
|
||||
#define BIO_get_conn_int port(b,port) BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,port)
|
||||
#define BIO_get_conn_int_port(b,port) BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,port)
|
||||
|
||||
|
||||
#define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
|
||||
|
||||
@@ -339,6 +349,12 @@ int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(),
|
||||
#define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?"a":NULL)
|
||||
#define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio)
|
||||
|
||||
#define BIO_BIND_NORMAL 0
|
||||
#define BIO_BIND_REUSEADDR_IF_UNUSED 1
|
||||
#define BIO_BIND_REUSEADDR 2
|
||||
#define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)
|
||||
#define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)
|
||||
|
||||
#define BIO_do_connect(b) BIO_do_handshake(b)
|
||||
#define BIO_do_accept(b) BIO_do_handshake(b)
|
||||
#define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)
|
||||
@@ -364,12 +380,17 @@ int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(),
|
||||
#define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp)
|
||||
#define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp)
|
||||
|
||||
#define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)
|
||||
#define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)
|
||||
|
||||
#define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||
BIO_CLOSE|BIO_FP_READ,name)
|
||||
#define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||
BIO_CLOSE|BIO_FP_WRITE,name)
|
||||
#define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||
BIO_CLOSE|BIO_FP_APPEND,name)
|
||||
#define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||
BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)
|
||||
|
||||
/* WARNING WARNING, this ups the reference count on the read bio of the
|
||||
* SSL structure. This is because the ssl read BIO is now pointed to by
|
||||
@@ -388,8 +409,11 @@ int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(),
|
||||
/* defined in evp.h */
|
||||
/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */
|
||||
|
||||
#define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)
|
||||
#define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm)
|
||||
#define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp)
|
||||
#define BIO_set_mem_eof_return(b,v) \
|
||||
BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)
|
||||
|
||||
/* For the BIO_f_buffer() type */
|
||||
#define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)
|
||||
@@ -486,8 +510,9 @@ BIO_METHOD *BIO_s_accept(void);
|
||||
BIO_METHOD *BIO_s_fd(void);
|
||||
BIO_METHOD *BIO_s_null(void);
|
||||
BIO_METHOD *BIO_f_null(void);
|
||||
BIO_METHOD *BIO_f_nbio_test(void);
|
||||
BIO_METHOD *BIO_f_buffer(void);
|
||||
BIO_METHOD *BIO_f_nbio_test(void);
|
||||
/* BIO_METHOD *BIO_f_ber(void); */
|
||||
|
||||
int BIO_sock_should_retry(int i);
|
||||
int BIO_sock_non_fatal_error(int error);
|
||||
@@ -498,9 +523,10 @@ int BIO_dump(BIO *b,char *bytes,int len);
|
||||
struct hostent *BIO_gethostbyname(char *name);
|
||||
int BIO_sock_error(int sock);
|
||||
int BIO_socket_ioctl(int fd, long type, unsigned long *arg);
|
||||
int BIO_get_port(char *str, short *port_ptr);
|
||||
int BIO_socket_nbio(int fd,int mode);
|
||||
int BIO_get_port(char *str, unsigned short *port_ptr);
|
||||
int BIO_get_host_ip(char *str, unsigned char *ip);
|
||||
int BIO_get_accept_socket(char *host_port);
|
||||
int BIO_get_accept_socket(char *host_port,int mode);
|
||||
int BIO_accept(int sock,char **ip_port);
|
||||
int BIO_sock_init(void );
|
||||
void BIO_sock_cleanup(void);
|
||||
@@ -552,6 +578,7 @@ BIO_METHOD *BIO_s_null();
|
||||
BIO_METHOD *BIO_f_null();
|
||||
BIO_METHOD *BIO_f_buffer();
|
||||
BIO_METHOD *BIO_f_nbio_test();
|
||||
/* BIO_METHOD *BIO_f_ber(); */
|
||||
|
||||
int BIO_sock_should_retry();
|
||||
int BIO_sock_non_fatal_error();
|
||||
@@ -562,6 +589,7 @@ int BIO_dump();
|
||||
struct hostent *BIO_gethostbyname();
|
||||
int BIO_sock_error();
|
||||
int BIO_socket_ioctl();
|
||||
int BIO_socket_nbio();
|
||||
int BIO_get_port();
|
||||
int BIO_get_host_ip();
|
||||
int BIO_get_accept_socket();
|
||||
@@ -579,7 +607,7 @@ BIO *BIO_new_accept();
|
||||
|
||||
void BIO_copy_next_retry();
|
||||
|
||||
int BIO_ghbn_ctrl();
|
||||
long BIO_ghbn_ctrl();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -639,23 +667,24 @@ int BIO_printf();
|
||||
/* Function codes. */
|
||||
#define BIO_F_ACPT_STATE 100
|
||||
#define BIO_F_BIO_ACCEPT 101
|
||||
#define BIO_F_BIO_CTRL 102
|
||||
#define BIO_F_BIO_GETS 103
|
||||
#define BIO_F_BIO_GET_ACCEPT_SOCKET 104
|
||||
#define BIO_F_BIO_GET_HOST_IP 105
|
||||
#define BIO_F_BIO_GET_PORT 106
|
||||
#define BIO_F_BIO_NEW 107
|
||||
#define BIO_F_BIO_NEW_FILE 108
|
||||
#define BIO_F_BIO_PUTS 109
|
||||
#define BIO_F_BIO_READ 110
|
||||
#define BIO_F_BIO_SOCK_INIT 111
|
||||
#define BIO_F_BIO_WRITE 112
|
||||
#define BIO_F_BUFFER_CTRL 113
|
||||
#define BIO_F_CONN_STATE 114
|
||||
#define BIO_F_FILE_CTRL 115
|
||||
#define BIO_F_MEM_WRITE 116
|
||||
#define BIO_F_SSL_NEW 117
|
||||
#define BIO_F_WSASTARTUP 118
|
||||
#define BIO_F_BIO_BER_GET_HEADER 102
|
||||
#define BIO_F_BIO_CTRL 103
|
||||
#define BIO_F_BIO_GETS 104
|
||||
#define BIO_F_BIO_GET_ACCEPT_SOCKET 105
|
||||
#define BIO_F_BIO_GET_HOST_IP 106
|
||||
#define BIO_F_BIO_GET_PORT 107
|
||||
#define BIO_F_BIO_NEW 108
|
||||
#define BIO_F_BIO_NEW_FILE 109
|
||||
#define BIO_F_BIO_PUTS 110
|
||||
#define BIO_F_BIO_READ 111
|
||||
#define BIO_F_BIO_SOCK_INIT 112
|
||||
#define BIO_F_BIO_WRITE 113
|
||||
#define BIO_F_BUFFER_CTRL 114
|
||||
#define BIO_F_CONN_STATE 115
|
||||
#define BIO_F_FILE_CTRL 116
|
||||
#define BIO_F_MEM_WRITE 117
|
||||
#define BIO_F_SSL_NEW 119
|
||||
#define BIO_F_WSASTARTUP 120
|
||||
|
||||
/* Reason codes. */
|
||||
#define BIO_R_ACCEPT_ERROR 100
|
||||
@@ -674,12 +703,17 @@ int BIO_printf();
|
||||
#define BIO_R_NO_PORT_DEFINED 113
|
||||
#define BIO_R_NO_PORT_SPECIFIED 114
|
||||
#define BIO_R_NULL_PARAMETER 115
|
||||
#define BIO_R_UNABLE_TO_BIND_SOCKET 116
|
||||
#define BIO_R_UNABLE_TO_CREATE_SOCKET 117
|
||||
#define BIO_R_UNABLE_TO_LISTEN_SOCKET 118
|
||||
#define BIO_R_UNINITALISED 119
|
||||
#define BIO_R_UNSUPPORTED_METHOD 120
|
||||
#define BIO_R_WSASTARTUP 121
|
||||
#define BIO_R_SOCKS_ID_AND_IDENT_DID_NOT_MATCH 116
|
||||
#define BIO_R_SOCKS_REJECTED_CONNECTION 117
|
||||
#define BIO_R_SOCKS_UNABLE_TO_TALK_TO_IDENT_SERVER 118
|
||||
#define BIO_R_SOCKS_UNKNOWN_ERROR 119
|
||||
#define BIO_R_TAG_MISMATCH 120
|
||||
#define BIO_R_UNABLE_TO_BIND_SOCKET 121
|
||||
#define BIO_R_UNABLE_TO_CREATE_SOCKET 122
|
||||
#define BIO_R_UNABLE_TO_LISTEN_SOCKET 123
|
||||
#define BIO_R_UNINITALISED 124
|
||||
#define BIO_R_UNSUPPORTED_METHOD 125
|
||||
#define BIO_R_WSASTARTUP 126
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@@ -65,6 +65,7 @@ static ERR_STRING_DATA BIO_str_functs[]=
|
||||
{
|
||||
{ERR_PACK(0,BIO_F_ACPT_STATE,0), "ACPT_STATE"},
|
||||
{ERR_PACK(0,BIO_F_BIO_ACCEPT,0), "BIO_accept"},
|
||||
{ERR_PACK(0,BIO_F_BIO_BER_GET_HEADER,0), "BIO_BER_GET_HEADER"},
|
||||
{ERR_PACK(0,BIO_F_BIO_CTRL,0), "BIO_ctrl"},
|
||||
{ERR_PACK(0,BIO_F_BIO_GETS,0), "BIO_gets"},
|
||||
{ERR_PACK(0,BIO_F_BIO_GET_ACCEPT_SOCKET,0), "BIO_get_accept_socket"},
|
||||
@@ -80,6 +81,7 @@ static ERR_STRING_DATA BIO_str_functs[]=
|
||||
{ERR_PACK(0,BIO_F_CONN_STATE,0), "CONN_STATE"},
|
||||
{ERR_PACK(0,BIO_F_FILE_CTRL,0), "FILE_CTRL"},
|
||||
{ERR_PACK(0,BIO_F_MEM_WRITE,0), "MEM_WRITE"},
|
||||
{ERR_PACK(0,BIO_F_SOCKS4A_STATE,0), "SOCKS4A_STATE"},
|
||||
{ERR_PACK(0,BIO_F_SSL_NEW,0), "SSL_NEW"},
|
||||
{ERR_PACK(0,BIO_F_WSASTARTUP,0), "WSASTARTUP"},
|
||||
{0,NULL},
|
||||
@@ -103,6 +105,11 @@ static ERR_STRING_DATA BIO_str_reasons[]=
|
||||
{BIO_R_NO_PORT_DEFINED ,"no port defined"},
|
||||
{BIO_R_NO_PORT_SPECIFIED ,"no port specified"},
|
||||
{BIO_R_NULL_PARAMETER ,"null parameter"},
|
||||
{BIO_R_SOCKS_ID_AND_IDENT_DID_NOT_MATCH ,"socks id and ident did not match"},
|
||||
{BIO_R_SOCKS_REJECTED_CONNECTION ,"socks rejected connection"},
|
||||
{BIO_R_SOCKS_UNABLE_TO_TALK_TO_IDENT_SERVER,"socks unable to talk to ident server"},
|
||||
{BIO_R_SOCKS_UNKNOWN_ERROR ,"socks unknown error"},
|
||||
{BIO_R_TAG_MISMATCH ,"tag mismatch"},
|
||||
{BIO_R_UNABLE_TO_BIND_SOCKET ,"unable to bind socket"},
|
||||
{BIO_R_UNABLE_TO_CREATE_SOCKET ,"unable to create socket"},
|
||||
{BIO_R_UNABLE_TO_LISTEN_SOCKET ,"unable to listen socket"},
|
||||
@@ -118,8 +125,8 @@ void ERR_load_BIO_strings()
|
||||
{
|
||||
static int init=1;
|
||||
|
||||
if (init);
|
||||
{;
|
||||
if (init)
|
||||
{
|
||||
init=0;
|
||||
#ifndef NO_ERR
|
||||
ERR_load_strings(ERR_LIB_BIO,BIO_str_functs);
|
||||
|
@@ -167,6 +167,7 @@ int outl;
|
||||
}
|
||||
|
||||
i=b->method->bread(b,out,outl);
|
||||
|
||||
if (i > 0) b->num_read+=(unsigned long)i;
|
||||
|
||||
if (cb != NULL)
|
||||
@@ -204,9 +205,16 @@ int inl;
|
||||
}
|
||||
|
||||
i=b->method->bwrite(b,in,inl);
|
||||
|
||||
if (i > 0) b->num_write+=(unsigned long)i;
|
||||
|
||||
if (cb != NULL)
|
||||
/* This is evil and not thread safe. If the BIO has been freed,
|
||||
* we must not call the callback. The only way to be able to
|
||||
* determine this is the reference count which is now invalid since
|
||||
* the memory has been free()ed.
|
||||
*/
|
||||
if (b->references <= 0) abort();
|
||||
if (cb != NULL) /* && (b->references >= 1)) */
|
||||
i=(int)cb(b,BIO_CB_WRITE|BIO_CB_RETURN,in,inl,
|
||||
0L,(long)i);
|
||||
return(i);
|
||||
|
@@ -82,6 +82,10 @@ typedef struct bio_accept_st
|
||||
|
||||
char *addr;
|
||||
int nbio;
|
||||
/* If 0, it means normal, if 1, do a connect on bind failure,
|
||||
* and if there is no-one listening, bind with SO_REUSEADDR.
|
||||
* If 2, always use SO_REUSEADDR. */
|
||||
int bind_mode;
|
||||
BIO *bio_chain;
|
||||
} BIO_ACCEPT;
|
||||
|
||||
@@ -162,6 +166,7 @@ BIO_ACCEPT *BIO_ACCEPT_new()
|
||||
|
||||
memset(ret,0,sizeof(BIO_ACCEPT));
|
||||
ret->accept_sock=INVALID_SOCKET;
|
||||
ret->bind_mode=BIO_BIND_NORMAL;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@@ -183,11 +188,7 @@ BIO *bio;
|
||||
if (c->accept_sock != INVALID_SOCKET)
|
||||
{
|
||||
shutdown(c->accept_sock,2);
|
||||
# ifdef WINDOWS
|
||||
closesocket(c->accept_sock);
|
||||
# else
|
||||
close(c->accept_sock);
|
||||
# endif
|
||||
c->accept_sock=INVALID_SOCKET;
|
||||
bio->num=INVALID_SOCKET;
|
||||
}
|
||||
@@ -217,7 +218,6 @@ BIO *b;
|
||||
BIO_ACCEPT *c;
|
||||
{
|
||||
BIO *bio=NULL,*dbio;
|
||||
unsigned long l=1;
|
||||
int s= -1;
|
||||
int i;
|
||||
|
||||
@@ -230,31 +230,24 @@ again:
|
||||
BIOerr(BIO_F_ACPT_STATE,BIO_R_NO_ACCEPT_PORT_SPECIFIED);
|
||||
return(-1);
|
||||
}
|
||||
s=BIO_get_accept_socket(c->param_addr);
|
||||
s=BIO_get_accept_socket(c->param_addr,c->bind_mode);
|
||||
if (s == INVALID_SOCKET)
|
||||
return(-1);
|
||||
|
||||
#ifdef FIONBIO
|
||||
if (c->accept_nbio)
|
||||
{
|
||||
i=BIO_socket_ioctl(b->num,FIONBIO,&l);
|
||||
if (i < 0)
|
||||
if (!BIO_socket_nbio(s,1))
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
closesocket(s);
|
||||
#else
|
||||
close(s);
|
||||
# endif
|
||||
BIOerr(BIO_F_ACPT_STATE,BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
c->accept_sock=s;
|
||||
b->num=s;
|
||||
c->state=ACPT_S_GET_ACCEPT_SOCKET;
|
||||
return(1);
|
||||
break;
|
||||
/* break; */
|
||||
case ACPT_S_GET_ACCEPT_SOCKET:
|
||||
if (b->next_bio != NULL)
|
||||
{
|
||||
@@ -269,17 +262,14 @@ again:
|
||||
BIO_set_callback(bio,BIO_get_callback(b));
|
||||
BIO_set_callback_arg(bio,BIO_get_callback_arg(b));
|
||||
|
||||
#ifdef FIONBIO
|
||||
if (c->nbio)
|
||||
{
|
||||
i=BIO_socket_ioctl(i,FIONBIO,&l);
|
||||
if (i < 0)
|
||||
if (!BIO_socket_nbio(i,1))
|
||||
{
|
||||
BIOerr(BIO_F_ACPT_STATE,BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If the accept BIO has an bio_chain, we dup it and
|
||||
* put the new socket at the end. */
|
||||
@@ -298,15 +288,9 @@ err:
|
||||
if (bio != NULL)
|
||||
BIO_free(bio);
|
||||
else if (s >= 0)
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
closesocket(s);
|
||||
#else
|
||||
close(s);
|
||||
# endif
|
||||
}
|
||||
return(0);
|
||||
break;
|
||||
/* break; */
|
||||
case ACPT_S_OK:
|
||||
if (b->next_bio == NULL)
|
||||
{
|
||||
@@ -314,10 +298,10 @@ err:
|
||||
goto again;
|
||||
}
|
||||
return(1);
|
||||
break;
|
||||
/* break; */
|
||||
default:
|
||||
return(0);
|
||||
break;
|
||||
/* break; */
|
||||
}
|
||||
|
||||
}
|
||||
@@ -417,13 +401,21 @@ char *ptr;
|
||||
case BIO_C_SET_NBIO:
|
||||
data->nbio=(int)num;
|
||||
break;
|
||||
case BIO_C_SET_FD:
|
||||
b->init=1;
|
||||
b->num= *((int *)ptr);
|
||||
data->accept_sock=b->num;
|
||||
data->state=ACPT_S_GET_ACCEPT_SOCKET;
|
||||
b->shutdown=(int)num;
|
||||
b->init=1;
|
||||
break;
|
||||
case BIO_C_GET_FD:
|
||||
if (b->init)
|
||||
{
|
||||
ip=(int *)ptr;
|
||||
if (ip != NULL)
|
||||
*ip=data->accept_sock;
|
||||
ret=b->num;
|
||||
ret=data->accept_sock;
|
||||
}
|
||||
else
|
||||
ret= -1;
|
||||
@@ -454,6 +446,12 @@ char *ptr;
|
||||
break;
|
||||
case BIO_CTRL_FLUSH:
|
||||
break;
|
||||
case BIO_C_SET_BIND_MODE:
|
||||
data->bind_mode=(int)num;
|
||||
break;
|
||||
case BIO_C_GET_BIND_MODE:
|
||||
ret=(long)data->bind_mode;
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
dbio=(BIO *)ptr;
|
||||
/* if (data->param_port) EAY EAY
|
||||
|
@@ -81,13 +81,12 @@ typedef struct bio_connect_st
|
||||
int nbio;
|
||||
|
||||
unsigned char ip[4];
|
||||
short port;
|
||||
unsigned short port;
|
||||
|
||||
struct sockaddr_in them;
|
||||
|
||||
/* int socket; this will be kept in bio->num so that it is
|
||||
* compatable with the bss_sock bio */
|
||||
int error;
|
||||
|
||||
/* called when the connection is initially made
|
||||
* callback(BIO,state,ret); The callback should return
|
||||
@@ -187,7 +186,7 @@ BIO_CONNECT *c;
|
||||
}
|
||||
}
|
||||
|
||||
if (p == NULL)
|
||||
if (c->param_port == NULL)
|
||||
{
|
||||
BIOerr(BIO_F_CONN_STATE,BIO_R_NO_PORT_SPECIFIED);
|
||||
ERR_add_error_data(2,"host=",c->param_hostname);
|
||||
@@ -203,7 +202,12 @@ BIO_CONNECT *c;
|
||||
break;
|
||||
|
||||
case BIO_CONN_S_GET_PORT:
|
||||
if (BIO_get_port(c->param_port,&c->port) <= 0)
|
||||
if (c->param_port == NULL)
|
||||
{
|
||||
abort();
|
||||
goto exit_loop;
|
||||
}
|
||||
else if (BIO_get_port(c->param_port,&c->port) <= 0)
|
||||
goto exit_loop;
|
||||
c->state=BIO_CONN_S_CREATE_SOCKET;
|
||||
break;
|
||||
@@ -235,12 +239,9 @@ BIO_CONNECT *c;
|
||||
break;
|
||||
|
||||
case BIO_CONN_S_NBIO:
|
||||
#ifdef FIONBIO
|
||||
if (c->nbio)
|
||||
{
|
||||
l=1;
|
||||
ret=BIO_socket_ioctl(b->num,FIONBIO,&l);
|
||||
if (ret < 0)
|
||||
if (!BIO_socket_nbio(b->num,1))
|
||||
{
|
||||
BIOerr(BIO_F_CONN_STATE,BIO_R_ERROR_SETTING_NBIO);
|
||||
ERR_add_error_data(4,"host=",
|
||||
@@ -249,7 +250,6 @@ BIO_CONNECT *c;
|
||||
goto exit_loop;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
c->state=BIO_CONN_S_CONNECT;
|
||||
|
||||
#ifdef SO_KEEPALIVE
|
||||
@@ -326,12 +326,10 @@ BIO_CONNECT *c;
|
||||
}
|
||||
}
|
||||
|
||||
if (1)
|
||||
{
|
||||
/* Loop does not exit */
|
||||
exit_loop:
|
||||
if (cb != NULL)
|
||||
ret=cb((BIO *)b,c->state,ret);
|
||||
}
|
||||
if (cb != NULL)
|
||||
ret=cb((BIO *)b,c->state,ret);
|
||||
end:
|
||||
return(ret);
|
||||
}
|
||||
@@ -353,7 +351,6 @@ BIO_CONNECT *BIO_CONNECT_new()
|
||||
ret->ip[3]=0;
|
||||
ret->port=0;
|
||||
memset((char *)&ret->them,0,sizeof(ret->them));
|
||||
ret->error=0;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@@ -395,11 +392,7 @@ BIO *bio;
|
||||
/* Only do a shutdown if things were established */
|
||||
if (c->state == BIO_CONN_S_OK)
|
||||
shutdown(bio->num,2);
|
||||
# ifdef WINDOWS
|
||||
closesocket(bio->num);
|
||||
# else
|
||||
close(bio->num);
|
||||
# endif
|
||||
bio->num=INVALID_SOCKET;
|
||||
}
|
||||
}
|
||||
@@ -442,11 +435,7 @@ int outl;
|
||||
if (out != NULL)
|
||||
{
|
||||
clear_socket_error();
|
||||
#if defined(WINDOWS)
|
||||
ret=recv(b->num,out,outl,0);
|
||||
#else
|
||||
ret=read(b->num,out,outl);
|
||||
#endif
|
||||
ret=readsocket(b->num,out,outl);
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ret <= 0)
|
||||
{
|
||||
@@ -473,11 +462,7 @@ int inl;
|
||||
}
|
||||
|
||||
clear_socket_error();
|
||||
#if defined(WINDOWS)
|
||||
ret=send(b->num,in,inl,0);
|
||||
#else
|
||||
ret=write(b->num,in,inl);
|
||||
#endif
|
||||
ret=writesocket(b->num,in,inl);
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ret <= 0)
|
||||
{
|
||||
@@ -559,9 +544,26 @@ char *ptr;
|
||||
data->param_port=BUF_strdup(ptr);
|
||||
}
|
||||
else if (num == 2)
|
||||
memcpy(data->ip,ptr,4);
|
||||
{
|
||||
char buf[16];
|
||||
|
||||
sprintf(buf,"%d.%d.%d.%d",
|
||||
ptr[0],ptr[1],ptr[2],ptr[3]);
|
||||
if (data->param_hostname != NULL)
|
||||
Free(data->param_hostname);
|
||||
data->param_hostname=BUF_strdup(buf);
|
||||
memcpy(&(data->ip[0]),ptr,4);
|
||||
}
|
||||
else if (num == 3)
|
||||
{
|
||||
char buf[16];
|
||||
|
||||
sprintf(buf,"%d",*(int *)ptr);
|
||||
if (data->param_port != NULL)
|
||||
Free(data->param_port);
|
||||
data->param_port=BUF_strdup(buf);
|
||||
data->port= *(int *)ptr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BIO_C_SET_NBIO:
|
||||
|
@@ -214,12 +214,14 @@ char *ptr;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_C_FILE_SEEK:
|
||||
case BIO_CTRL_RESET:
|
||||
ret=(long)fseek(fp,num,0);
|
||||
break;
|
||||
case BIO_CTRL_EOF:
|
||||
ret=(long)feof(fp);
|
||||
break;
|
||||
case BIO_C_FILE_TELL:
|
||||
case BIO_CTRL_INFO:
|
||||
ret=ftell(fp);
|
||||
break;
|
||||
|
@@ -92,6 +92,9 @@ static BIO_METHOD mem_method=
|
||||
mem_free,
|
||||
};
|
||||
|
||||
/* bio->num is used to hold the value to return on 'empty', if it is
|
||||
* 0, should_retry is not set */
|
||||
|
||||
BIO_METHOD *BIO_s_mem()
|
||||
{
|
||||
return(&mem_method);
|
||||
@@ -106,7 +109,7 @@ BIO *bi;
|
||||
return(0);
|
||||
bi->shutdown=1;
|
||||
bi->init=1;
|
||||
bi->num=0;
|
||||
bi->num= -1;
|
||||
bi->ptr=(char *)b;
|
||||
return(1);
|
||||
}
|
||||
@@ -151,8 +154,9 @@ int outl;
|
||||
}
|
||||
else if (bm->length == 0)
|
||||
{
|
||||
BIO_set_retry_read(b);
|
||||
ret= -1;
|
||||
if (b->num != 0)
|
||||
BIO_set_retry_read(b);
|
||||
ret= b->num;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
@@ -204,6 +208,9 @@ char *ptr;
|
||||
case BIO_CTRL_EOF:
|
||||
ret=(long)(bm->length == 0);
|
||||
break;
|
||||
case BIO_C_SET_BUF_MEM_EOF_RETURN:
|
||||
b->num=(int)num;
|
||||
break;
|
||||
case BIO_CTRL_INFO:
|
||||
ret=(long)bm->length;
|
||||
if (ptr != NULL)
|
||||
|
@@ -189,11 +189,7 @@ BIO *a;
|
||||
{
|
||||
#ifndef BIO_FD
|
||||
shutdown(a->num,2);
|
||||
# ifdef WINDOWS
|
||||
closesocket(a->num);
|
||||
# else
|
||||
close(a->num);
|
||||
# endif
|
||||
#else /* BIO_FD */
|
||||
close(a->num);
|
||||
#endif
|
||||
@@ -218,9 +214,9 @@ int outl;
|
||||
|
||||
if (out != NULL)
|
||||
{
|
||||
#if defined(WINDOWS) && !defined(BIO_FD)
|
||||
#ifndef BIO_FD
|
||||
clear_socket_error();
|
||||
ret=recv(b->num,out,outl,0);
|
||||
ret=readsocket(b->num,out,outl);
|
||||
#else
|
||||
clear_sys_error();
|
||||
ret=read(b->num,out,outl);
|
||||
@@ -250,9 +246,9 @@ int inl;
|
||||
{
|
||||
int ret;
|
||||
|
||||
#if defined(WINDOWS) && !defined(BIO_FD)
|
||||
#ifndef BIO_FD
|
||||
clear_socket_error();
|
||||
ret=send(b->num,in,inl,0);
|
||||
ret=writesocket(b->num,in,inl);
|
||||
#else
|
||||
clear_sys_error();
|
||||
ret=write(b->num,in,inl);
|
||||
@@ -286,14 +282,21 @@ char *ptr;
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_CTRL_RESET:
|
||||
num=0;
|
||||
case BIO_C_FILE_SEEK:
|
||||
#ifdef BIO_FD
|
||||
ret=(long)lseek(b->num,0,0);
|
||||
ret=(long)lseek(b->num,num,0);
|
||||
#else
|
||||
ret=0;
|
||||
#endif
|
||||
break;
|
||||
case BIO_C_FILE_TELL:
|
||||
case BIO_CTRL_INFO:
|
||||
#ifdef BIO_FD
|
||||
ret=(long)lseek(b->num,0,1);
|
||||
#else
|
||||
ret=0;
|
||||
#endif
|
||||
break;
|
||||
case BIO_C_SET_FD:
|
||||
#ifndef BIO_FD
|
||||
@@ -329,7 +332,6 @@ char *ptr;
|
||||
case BIO_CTRL_FLUSH:
|
||||
ret=1;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
ret=0;
|
||||
break;
|
||||
@@ -377,7 +379,7 @@ int i;
|
||||
|
||||
if ((i == 0) || (i == -1))
|
||||
{
|
||||
#if !defined(BIO_FD) && defined(WINDOWS)
|
||||
#ifndef BIO_FD
|
||||
err=get_last_socket_error();
|
||||
#else
|
||||
err=get_last_sys_error();
|
||||
@@ -411,8 +413,10 @@ int err;
|
||||
case WSAEWOULDBLOCK:
|
||||
# endif
|
||||
|
||||
# if defined(WSAENOTCONN)
|
||||
# if 0 /* This appears to always be an error */
|
||||
# if defined(WSAENOTCONN)
|
||||
case WSAENOTCONN:
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -452,7 +456,7 @@ int err;
|
||||
case EALREADY:
|
||||
#endif
|
||||
return(1);
|
||||
break;
|
||||
/* break; */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
0
crypto/bio/cd
Normal file
0
crypto/bio/cd
Normal file
0
crypto/bio/fg
Normal file
0
crypto/bio/fg
Normal file
0
crypto/bio/grep
Normal file
0
crypto/bio/grep
Normal file
0
crypto/bio/vi
Normal file
0
crypto/bio/vi
Normal file
2
crypto/bn/DSA
Normal file
2
crypto/bn/DSA
Normal file
@@ -0,0 +1,2 @@
|
||||
DSA wants 64*32 to use word mont mul, but
|
||||
RSA wants to use full.
|
@@ -13,9 +13,9 @@ MAKEDEPEND= makedepend -f Makefile.ssl
|
||||
MAKEFILE= Makefile.ssl
|
||||
AR= ar r
|
||||
|
||||
BN_MULW= bn_mulw.o
|
||||
BN_ASM= bn_asm.o
|
||||
# or use
|
||||
#BN_MULW= bn86-elf.o
|
||||
#BN_ASM= bn86-elf.o
|
||||
|
||||
CFLAGS= $(INCLUDES) $(CFLAG)
|
||||
|
||||
@@ -26,16 +26,15 @@ TEST=bntest.c exptest.c
|
||||
APPS=
|
||||
|
||||
LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mod.c bn_mul.c \
|
||||
bn_print.c bn_rand.c bn_shift.c bn_sub.c bn_word.c bn_blind.c \
|
||||
bn_gcd.c bn_prime.c $(ERRC).c bn_sqr.c bn_mulw.c bn_recp.c bn_mont.c \
|
||||
bn_mpi.c
|
||||
|
||||
LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_mod.o bn_mul.o \
|
||||
bn_print.o bn_rand.o bn_shift.o bn_sub.o bn_word.o bn_blind.o \
|
||||
bn_gcd.o bn_prime.o $(ERRC).o bn_sqr.o $(BN_MULW) bn_recp.o bn_mont.o \
|
||||
bn_mpi.o
|
||||
LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mul.c \
|
||||
bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \
|
||||
bn_gcd.c bn_prime.c $(ERRC).c bn_sqr.c bn_asm.c bn_recp.c bn_mont.c \
|
||||
bn_mpi.c bn_exp2.c
|
||||
|
||||
LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_mul.o \
|
||||
bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \
|
||||
bn_gcd.o bn_prime.o $(ERRC).o bn_sqr.o $(BN_ASM) bn_recp.o bn_mont.o \
|
||||
bn_mpi.o bn_exp2.o
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
@@ -65,23 +64,48 @@ lib: $(LIBOBJ)
|
||||
asm/bn86-elf.o: asm/bn86unix.cpp
|
||||
$(CPP) -DELF asm/bn86unix.cpp | as -o asm/bn86-elf.o
|
||||
|
||||
asm/co86-elf.o: asm/co86unix.cpp
|
||||
$(CPP) -DELF asm/co86unix.cpp | as -o asm/co86-elf.o
|
||||
|
||||
# solaris
|
||||
asm/bn86-sol.o: asm/bn86unix.cpp
|
||||
$(CC) -E -DSOL asm/bn86unix.cpp | sed 's/^#.*//' > asm/bn86-sol.s
|
||||
as -o asm/bn86-sol.o asm/bn86-sol.s
|
||||
rm -f asm/bn86-sol.s
|
||||
|
||||
asm/co86-sol.o: asm/co86unix.cpp
|
||||
$(CC) -E -DSOL asm/co86unix.cpp | sed 's/^#.*//' > asm/co86-sol.s
|
||||
as -o asm/co86-sol.o asm/co86-sol.s
|
||||
rm -f asm/co86-sol.s
|
||||
|
||||
# a.out
|
||||
asm/bn86-out.o: asm/bn86unix.cpp
|
||||
$(CPP) -DOUT asm/bn86unix.cpp | as -o asm/bn86-out.o
|
||||
|
||||
asm/co86-out.o: asm/co86unix.cpp
|
||||
$(CPP) -DOUT asm/co86unix.cpp | as -o asm/co86-out.o
|
||||
|
||||
# bsdi
|
||||
asm/bn86bsdi.o: asm/bn86unix.cpp
|
||||
$(CPP) -DBSDI asm/bn86unix.cpp | as -o asm/bn86bsdi.o
|
||||
$(CPP) -DBSDI asm/bn86unix.cpp | sed 's/ :/:/' | as -o asm/bn86bsdi.o
|
||||
|
||||
asm/co86bsdi.o: asm/co86unix.cpp
|
||||
$(CPP) -DBSDI asm/co86unix.cpp | sed 's/ :/:/' | as -o asm/co86bsdi.o
|
||||
|
||||
asm/bn86unix.cpp:
|
||||
(cd asm; perl bn-586.pl cpp >bn86unix.cpp )
|
||||
|
||||
asm/co86unix.cpp:
|
||||
(cd asm; perl co-586.pl cpp >co86unix.cpp )
|
||||
|
||||
# MIPS 64 bit assember
|
||||
asm/mips3.o: asm/mips3.s
|
||||
/usr/bin/as -mips3 -O2 -o asm/mips3.o asm/mips3.s
|
||||
|
||||
# MIPS 32 bit assember
|
||||
asm/mips1.o: asm/mips1.s
|
||||
/usr/bin/as -O2 -o asm/mips1.o asm/mips1.s
|
||||
|
||||
files:
|
||||
perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
|
||||
|
||||
@@ -123,7 +147,7 @@ dclean:
|
||||
mv -f Makefile.new $(MAKEFILE)
|
||||
|
||||
clean:
|
||||
/bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff bn_mulw.s
|
||||
/bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff bn_asm.s
|
||||
|
||||
errors:
|
||||
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).org # special case .org
|
||||
|
0
crypto/bn/alpha.s
Normal file
0
crypto/bn/alpha.s
Normal file
BIN
crypto/bn/asm/a.out
Normal file
BIN
crypto/bn/asm/a.out
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
533
crypto/bn/asm/alpha.s.works
Normal file
533
crypto/bn/asm/alpha.s.works
Normal file
@@ -0,0 +1,533 @@
|
||||
|
||||
# DEC Alpha assember
|
||||
# The bn_div64 is actually gcc output but the other parts are hand done.
|
||||
# Thanks to tzeruch@ceddec.com for sending me the gcc output for
|
||||
# bn_div64.
|
||||
# I've gone back and re-done most of routines.
|
||||
# The key thing to remeber for the 164 CPU is that while a
|
||||
# multiply operation takes 8 cycles, another one can only be issued
|
||||
# after 4 cycles have elapsed. I've done modification to help
|
||||
# improve this. Also, normally, a ld instruction will not be available
|
||||
# for about 3 cycles.
|
||||
.file 1 "bn_asm.c"
|
||||
.set noat
|
||||
gcc2_compiled.:
|
||||
__gnu_compiled_c:
|
||||
.text
|
||||
.align 3
|
||||
.globl bn_mul_add_words
|
||||
.ent bn_mul_add_words
|
||||
bn_mul_add_words:
|
||||
bn_mul_add_words..ng:
|
||||
.frame $30,0,$26,0
|
||||
.prologue 0
|
||||
.align 5
|
||||
subq $18,4,$18
|
||||
bis $31,$31,$0
|
||||
blt $18,$43 # if we are -1, -2, -3 or -4 goto tail code
|
||||
ldq $20,0($17) # 1 1
|
||||
ldq $1,0($16) # 1 1
|
||||
.align 3
|
||||
$42:
|
||||
mulq $20,$19,$5 # 1 2 1 ######
|
||||
ldq $21,8($17) # 2 1
|
||||
ldq $2,8($16) # 2 1
|
||||
umulh $20,$19,$20 # 1 2 ######
|
||||
ldq $27,16($17) # 3 1
|
||||
ldq $3,16($16) # 3 1
|
||||
mulq $21,$19,$6 # 2 2 1 ######
|
||||
ldq $28,24($17) # 4 1
|
||||
addq $1,$5,$1 # 1 2 2
|
||||
ldq $4,24($16) # 4 1
|
||||
umulh $21,$19,$21 # 2 2 ######
|
||||
cmpult $1,$5,$22 # 1 2 3 1
|
||||
addq $20,$22,$20 # 1 3 1
|
||||
addq $1,$0,$1 # 1 2 3 1
|
||||
mulq $27,$19,$7 # 3 2 1 ######
|
||||
cmpult $1,$0,$0 # 1 2 3 2
|
||||
addq $2,$6,$2 # 2 2 2
|
||||
addq $20,$0,$0 # 1 3 2
|
||||
cmpult $2,$6,$23 # 2 2 3 1
|
||||
addq $21,$23,$21 # 2 3 1
|
||||
umulh $27,$19,$27 # 3 2 ######
|
||||
addq $2,$0,$2 # 2 2 3 1
|
||||
cmpult $2,$0,$0 # 2 2 3 2
|
||||
subq $18,4,$18
|
||||
mulq $28,$19,$8 # 4 2 1 ######
|
||||
addq $21,$0,$0 # 2 3 2
|
||||
addq $3,$7,$3 # 3 2 2
|
||||
addq $16,32,$16
|
||||
cmpult $3,$7,$24 # 3 2 3 1
|
||||
stq $1,-32($16) # 1 2 4
|
||||
umulh $28,$19,$28 # 4 2 ######
|
||||
addq $27,$24,$27 # 3 3 1
|
||||
addq $3,$0,$3 # 3 2 3 1
|
||||
stq $2,-24($16) # 2 2 4
|
||||
cmpult $3,$0,$0 # 3 2 3 2
|
||||
stq $3,-16($16) # 3 2 4
|
||||
addq $4,$8,$4 # 4 2 2
|
||||
addq $27,$0,$0 # 3 3 2
|
||||
cmpult $4,$8,$25 # 4 2 3 1
|
||||
addq $17,32,$17
|
||||
addq $28,$25,$28 # 4 3 1
|
||||
addq $4,$0,$4 # 4 2 3 1
|
||||
cmpult $4,$0,$0 # 4 2 3 2
|
||||
stq $4,-8($16) # 4 2 4
|
||||
addq $28,$0,$0 # 4 3 2
|
||||
blt $18,$43
|
||||
|
||||
ldq $20,0($17) # 1 1
|
||||
ldq $1,0($16) # 1 1
|
||||
|
||||
br $42
|
||||
|
||||
.align 4
|
||||
$45:
|
||||
ldq $20,0($17) # 4 1
|
||||
ldq $1,0($16) # 4 1
|
||||
mulq $20,$19,$5 # 4 2 1
|
||||
subq $18,1,$18
|
||||
addq $16,8,$16
|
||||
addq $17,8,$17
|
||||
umulh $20,$19,$20 # 4 2
|
||||
addq $1,$5,$1 # 4 2 2
|
||||
cmpult $1,$5,$22 # 4 2 3 1
|
||||
addq $20,$22,$20 # 4 3 1
|
||||
addq $1,$0,$1 # 4 2 3 1
|
||||
cmpult $1,$0,$0 # 4 2 3 2
|
||||
addq $20,$0,$0 # 4 3 2
|
||||
stq $1,-8($16) # 4 2 4
|
||||
bgt $18,$45
|
||||
ret $31,($26),1 # else exit
|
||||
|
||||
.align 4
|
||||
$43:
|
||||
addq $18,4,$18
|
||||
bgt $18,$45 # goto tail code
|
||||
ret $31,($26),1 # else exit
|
||||
|
||||
.end bn_mul_add_words
|
||||
.align 3
|
||||
.globl bn_mul_words
|
||||
.ent bn_mul_words
|
||||
bn_mul_words:
|
||||
bn_mul_words..ng:
|
||||
.frame $30,0,$26,0
|
||||
.prologue 0
|
||||
.align 5
|
||||
subq $18,4,$18
|
||||
bis $31,$31,$0
|
||||
blt $18,$143 # if we are -1, -2, -3 or -4 goto tail code
|
||||
ldq $20,0($17) # 1 1
|
||||
.align 3
|
||||
$142:
|
||||
|
||||
mulq $20,$19,$5 # 1 2 1 #####
|
||||
ldq $21,8($17) # 2 1
|
||||
ldq $27,16($17) # 3 1
|
||||
umulh $20,$19,$20 # 1 2 #####
|
||||
ldq $28,24($17) # 4 1
|
||||
mulq $21,$19,$6 # 2 2 1 #####
|
||||
addq $5,$0,$5 # 1 2 3 1
|
||||
subq $18,4,$18
|
||||
cmpult $5,$0,$0 # 1 2 3 2
|
||||
umulh $21,$19,$21 # 2 2 #####
|
||||
addq $20,$0,$0 # 1 3 2
|
||||
addq $17,32,$17
|
||||
addq $6,$0,$6 # 2 2 3 1
|
||||
mulq $27,$19,$7 # 3 2 1 #####
|
||||
cmpult $6,$0,$0 # 2 2 3 2
|
||||
addq $21,$0,$0 # 2 3 2
|
||||
addq $16,32,$16
|
||||
umulh $27,$19,$27 # 3 2 #####
|
||||
stq $5,-32($16) # 1 2 4
|
||||
mulq $28,$19,$8 # 4 2 1 #####
|
||||
addq $7,$0,$7 # 3 2 3 1
|
||||
stq $6,-24($16) # 2 2 4
|
||||
cmpult $7,$0,$0 # 3 2 3 2
|
||||
umulh $28,$19,$28 # 4 2 #####
|
||||
addq $27,$0,$0 # 3 3 2
|
||||
stq $7,-16($16) # 3 2 4
|
||||
addq $8,$0,$8 # 4 2 3 1
|
||||
cmpult $8,$0,$0 # 4 2 3 2
|
||||
|
||||
addq $28,$0,$0 # 4 3 2
|
||||
|
||||
stq $8,-8($16) # 4 2 4
|
||||
|
||||
blt $18,$143
|
||||
|
||||
ldq $20,0($17) # 1 1
|
||||
|
||||
br $142
|
||||
|
||||
.align 4
|
||||
$145:
|
||||
ldq $20,0($17) # 4 1
|
||||
mulq $20,$19,$5 # 4 2 1
|
||||
subq $18,1,$18
|
||||
umulh $20,$19,$20 # 4 2
|
||||
addq $5,$0,$5 # 4 2 3 1
|
||||
addq $16,8,$16
|
||||
cmpult $5,$0,$0 # 4 2 3 2
|
||||
addq $17,8,$17
|
||||
addq $20,$0,$0 # 4 3 2
|
||||
stq $5,-8($16) # 4 2 4
|
||||
|
||||
bgt $18,$145
|
||||
ret $31,($26),1 # else exit
|
||||
|
||||
.align 4
|
||||
$143:
|
||||
addq $18,4,$18
|
||||
bgt $18,$145 # goto tail code
|
||||
ret $31,($26),1 # else exit
|
||||
|
||||
.end bn_mul_words
|
||||
.align 3
|
||||
.globl bn_sqr_words
|
||||
.ent bn_sqr_words
|
||||
bn_sqr_words:
|
||||
bn_sqr_words..ng:
|
||||
.frame $30,0,$26,0
|
||||
.prologue 0
|
||||
|
||||
subq $18,4,$18
|
||||
blt $18,$543 # if we are -1, -2, -3 or -4 goto tail code
|
||||
ldq $20,0($17) # 1 1
|
||||
.align 3
|
||||
$542:
|
||||
mulq $20,$20,$5 ######
|
||||
ldq $21,8($17) # 1 1
|
||||
subq $18,4
|
||||
umulh $20,$20,$1 ######
|
||||
ldq $27,16($17) # 1 1
|
||||
mulq $21,$21,$6 ######
|
||||
ldq $28,24($17) # 1 1
|
||||
stq $5,0($16) # r[0]
|
||||
umulh $21,$21,$2 ######
|
||||
stq $1,8($16) # r[1]
|
||||
mulq $27,$27,$7 ######
|
||||
stq $6,16($16) # r[0]
|
||||
umulh $27,$27,$3 ######
|
||||
stq $2,24($16) # r[1]
|
||||
mulq $28,$28,$8 ######
|
||||
stq $7,32($16) # r[0]
|
||||
umulh $28,$28,$4 ######
|
||||
stq $3,40($16) # r[1]
|
||||
|
||||
addq $16,64,$16
|
||||
addq $17,32,$17
|
||||
stq $8,-16($16) # r[0]
|
||||
stq $4,-8($16) # r[1]
|
||||
|
||||
blt $18,$543
|
||||
ldq $20,0($17) # 1 1
|
||||
br $542
|
||||
|
||||
$442:
|
||||
ldq $20,0($17) # a[0]
|
||||
mulq $20,$20,$5 # a[0]*w low part r2
|
||||
addq $16,16,$16
|
||||
addq $17,8,$17
|
||||
subq $18,1,$18
|
||||
umulh $20,$20,$1 # a[0]*w high part r3
|
||||
stq $5,-16($16) # r[0]
|
||||
stq $1,-8($16) # r[1]
|
||||
|
||||
bgt $18,$442
|
||||
ret $31,($26),1 # else exit
|
||||
|
||||
.align 4
|
||||
$543:
|
||||
addq $18,4,$18
|
||||
bgt $18,$442 # goto tail code
|
||||
ret $31,($26),1 # else exit
|
||||
.end bn_sqr_words
|
||||
|
||||
.align 3
|
||||
.globl bn_add_words
|
||||
.ent bn_add_words
|
||||
bn_add_words:
|
||||
bn_add_words..ng:
|
||||
.frame $30,0,$26,0
|
||||
.prologue 0
|
||||
|
||||
subq $19,4,$19
|
||||
bis $31,$31,$0 # carry = 0
|
||||
blt $19,$900
|
||||
ldq $5,0($17) # a[0]
|
||||
ldq $1,0($18) # b[1]
|
||||
.align 3
|
||||
$901:
|
||||
addq $1,$5,$1 # r=a+b;
|
||||
ldq $6,8($17) # a[1]
|
||||
cmpult $1,$5,$22 # did we overflow?
|
||||
ldq $2,8($18) # b[1]
|
||||
addq $1,$0,$1 # c+= overflow
|
||||
ldq $7,16($17) # a[2]
|
||||
cmpult $1,$0,$0 # overflow?
|
||||
ldq $3,16($18) # b[2]
|
||||
addq $0,$22,$0
|
||||
ldq $8,24($17) # a[3]
|
||||
addq $2,$6,$2 # r=a+b;
|
||||
ldq $4,24($18) # b[3]
|
||||
cmpult $2,$6,$23 # did we overflow?
|
||||
addq $3,$7,$3 # r=a+b;
|
||||
addq $2,$0,$2 # c+= overflow
|
||||
cmpult $3,$7,$24 # did we overflow?
|
||||
cmpult $2,$0,$0 # overflow?
|
||||
addq $4,$8,$4 # r=a+b;
|
||||
addq $0,$23,$0
|
||||
cmpult $4,$8,$25 # did we overflow?
|
||||
addq $3,$0,$3 # c+= overflow
|
||||
stq $1,0($16) # r[0]=c
|
||||
cmpult $3,$0,$0 # overflow?
|
||||
stq $2,8($16) # r[1]=c
|
||||
addq $0,$24,$0
|
||||
stq $3,16($16) # r[2]=c
|
||||
addq $4,$0,$4 # c+= overflow
|
||||
subq $19,4,$19 # loop--
|
||||
cmpult $4,$0,$0 # overflow?
|
||||
addq $17,32,$17 # a++
|
||||
addq $0,$25,$0
|
||||
stq $4,24($16) # r[3]=c
|
||||
addq $18,32,$18 # b++
|
||||
addq $16,32,$16 # r++
|
||||
|
||||
blt $19,$900
|
||||
ldq $5,0($17) # a[0]
|
||||
ldq $1,0($18) # b[1]
|
||||
br $901
|
||||
.align 4
|
||||
$945:
|
||||
ldq $5,0($17) # a[0]
|
||||
ldq $1,0($18) # b[1]
|
||||
addq $1,$5,$1 # r=a+b;
|
||||
subq $19,1,$19 # loop--
|
||||
addq $1,$0,$1 # c+= overflow
|
||||
addq $17,8,$17 # a++
|
||||
cmpult $1,$5,$22 # did we overflow?
|
||||
cmpult $1,$0,$0 # overflow?
|
||||
addq $18,8,$18 # b++
|
||||
stq $1,0($16) # r[0]=c
|
||||
addq $0,$22,$0
|
||||
addq $16,8,$16 # r++
|
||||
|
||||
bgt $19,$945
|
||||
ret $31,($26),1 # else exit
|
||||
|
||||
$900:
|
||||
addq $19,4,$19
|
||||
bgt $19,$945 # goto tail code
|
||||
ret $31,($26),1 # else exit
|
||||
.end bn_add_words
|
||||
|
||||
#
|
||||
# What follows was taken directly from the C compiler with a few
|
||||
# hacks to redo the lables.
|
||||
#
|
||||
.text
|
||||
.align 3
|
||||
.globl bn_div64
|
||||
.ent bn_div64
|
||||
bn_div64:
|
||||
ldgp $29,0($27)
|
||||
bn_div64..ng:
|
||||
lda $30,-48($30)
|
||||
.frame $30,48,$26,0
|
||||
stq $26,0($30)
|
||||
stq $9,8($30)
|
||||
stq $10,16($30)
|
||||
stq $11,24($30)
|
||||
stq $12,32($30)
|
||||
stq $13,40($30)
|
||||
.mask 0x4003e00,-48
|
||||
.prologue 1
|
||||
bis $16,$16,$9
|
||||
bis $17,$17,$10
|
||||
bis $18,$18,$11
|
||||
bis $31,$31,$13
|
||||
bis $31,2,$12
|
||||
bne $11,$119
|
||||
lda $0,-1
|
||||
br $31,$136
|
||||
.align 4
|
||||
$119:
|
||||
bis $11,$11,$16
|
||||
jsr $26,BN_num_bits_word
|
||||
ldgp $29,0($26)
|
||||
subq $0,64,$1
|
||||
beq $1,$120
|
||||
bis $31,1,$1
|
||||
sll $1,$0,$1
|
||||
cmpule $9,$1,$1
|
||||
bne $1,$120
|
||||
# lda $16,_IO_stderr_
|
||||
# lda $17,$C32
|
||||
# bis $0,$0,$18
|
||||
# jsr $26,fprintf
|
||||
# ldgp $29,0($26)
|
||||
jsr $26,abort
|
||||
ldgp $29,0($26)
|
||||
.align 4
|
||||
$120:
|
||||
bis $31,64,$3
|
||||
cmpult $9,$11,$2
|
||||
subq $3,$0,$1
|
||||
addl $1,$31,$0
|
||||
subq $9,$11,$1
|
||||
cmoveq $2,$1,$9
|
||||
beq $0,$122
|
||||
zapnot $0,15,$2
|
||||
subq $3,$0,$1
|
||||
sll $11,$2,$11
|
||||
sll $9,$2,$3
|
||||
srl $10,$1,$1
|
||||
sll $10,$2,$10
|
||||
bis $3,$1,$9
|
||||
$122:
|
||||
srl $11,32,$5
|
||||
zapnot $11,15,$6
|
||||
lda $7,-1
|
||||
.align 5
|
||||
$123:
|
||||
srl $9,32,$1
|
||||
subq $1,$5,$1
|
||||
bne $1,$126
|
||||
zapnot $7,15,$27
|
||||
br $31,$127
|
||||
.align 4
|
||||
$126:
|
||||
bis $9,$9,$24
|
||||
bis $5,$5,$25
|
||||
divqu $24,$25,$27
|
||||
$127:
|
||||
srl $10,32,$4
|
||||
.align 5
|
||||
$128:
|
||||
mulq $27,$5,$1
|
||||
subq $9,$1,$3
|
||||
zapnot $3,240,$1
|
||||
bne $1,$129
|
||||
mulq $6,$27,$2
|
||||
sll $3,32,$1
|
||||
addq $1,$4,$1
|
||||
cmpule $2,$1,$2
|
||||
bne $2,$129
|
||||
subq $27,1,$27
|
||||
br $31,$128
|
||||
.align 4
|
||||
$129:
|
||||
mulq $27,$6,$1
|
||||
mulq $27,$5,$4
|
||||
srl $1,32,$3
|
||||
sll $1,32,$1
|
||||
addq $4,$3,$4
|
||||
cmpult $10,$1,$2
|
||||
subq $10,$1,$10
|
||||
addq $2,$4,$2
|
||||
cmpult $9,$2,$1
|
||||
bis $2,$2,$4
|
||||
beq $1,$134
|
||||
addq $9,$11,$9
|
||||
subq $27,1,$27
|
||||
$134:
|
||||
subl $12,1,$12
|
||||
subq $9,$4,$9
|
||||
beq $12,$124
|
||||
sll $27,32,$13
|
||||
sll $9,32,$2
|
||||
srl $10,32,$1
|
||||
sll $10,32,$10
|
||||
bis $2,$1,$9
|
||||
br $31,$123
|
||||
.align 4
|
||||
$124:
|
||||
bis $13,$27,$0
|
||||
$136:
|
||||
ldq $26,0($30)
|
||||
ldq $9,8($30)
|
||||
ldq $10,16($30)
|
||||
ldq $11,24($30)
|
||||
ldq $12,32($30)
|
||||
ldq $13,40($30)
|
||||
addq $30,48,$30
|
||||
ret $31,($26),1
|
||||
.end bn_div64
|
||||
|
||||
.set noat
|
||||
.text
|
||||
.align 3
|
||||
.globl bn_sub_words
|
||||
.ent bn_sub_words
|
||||
bn_sub_words:
|
||||
bn_sub_words..ng:
|
||||
.frame $30,0,$26,0
|
||||
.prologue 0
|
||||
|
||||
subq $19, 4, $19
|
||||
bis $31, $31, $0
|
||||
blt $19, $100
|
||||
ldq $1, 0($17)
|
||||
ldq $2, 0($18)
|
||||
$101:
|
||||
ldq $3, 8($17)
|
||||
cmpult $1, $2, $4
|
||||
ldq $5, 8($18)
|
||||
subq $1, $2, $1
|
||||
ldq $6, 16($17)
|
||||
cmpult $1, $0, $2
|
||||
ldq $7, 16($18)
|
||||
subq $1, $0, $23
|
||||
ldq $8, 24($17)
|
||||
addq $2, $4, $0
|
||||
cmpult $3, $5, $24
|
||||
subq $3, $5, $3
|
||||
ldq $22, 24($18)
|
||||
cmpult $3, $0, $5
|
||||
subq $3, $0, $25
|
||||
addq $5, $24, $0
|
||||
cmpult $6, $7, $27
|
||||
subq $6, $7, $6
|
||||
stq $23, 0($16)
|
||||
cmpult $6, $0, $7
|
||||
subq $6, $0, $28
|
||||
addq $7, $27, $0
|
||||
cmpult $8, $22, $21
|
||||
subq $8, $22, $8
|
||||
stq $25, 8($16)
|
||||
cmpult $8, $0, $22
|
||||
subq $8, $0, $20
|
||||
addq $22, $21, $0
|
||||
stq $28, 16($16)
|
||||
subq $19, 4, $19
|
||||
stq $20, 24($16)
|
||||
addq $17, 32, $17
|
||||
addq $18, 32, $18
|
||||
addq $16, 32, $16
|
||||
blt $19, $100
|
||||
ldq $1, 0($17)
|
||||
ldq $2, 0($18)
|
||||
br $101
|
||||
$102:
|
||||
ldq $1, 0($17)
|
||||
ldq $2, 0($18)
|
||||
cmpult $1, $2, $27
|
||||
subq $1, $2, $1
|
||||
cmpult $1, $0, $2
|
||||
subq $1, $0, $1
|
||||
stq $1, 0($16)
|
||||
addq $2, $27, $0
|
||||
addq $17, 8, $17
|
||||
addq $18, 8, $18
|
||||
addq $16, 8, $16
|
||||
subq $19, 1, $19
|
||||
bgt $19, $102
|
||||
ret $31,($26),1
|
||||
$100:
|
||||
addq $19, 4, $19
|
||||
bgt $19, $102
|
||||
$103:
|
||||
ret $31,($26),1
|
||||
.end bn_sub_words
|
119
crypto/bn/asm/alpha.works/add.pl
Normal file
119
crypto/bn/asm/alpha.works/add.pl
Normal file
@@ -0,0 +1,119 @@
|
||||
#!/usr/local/bin/perl
|
||||
# alpha assember
|
||||
|
||||
sub bn_add_words
|
||||
{
|
||||
local($name)=@_;
|
||||
local($cc,$a,$b,$r);
|
||||
|
||||
&init_pool(4);
|
||||
($cc)=GR("r0");
|
||||
|
||||
$rp=&wparam(0);
|
||||
$ap=&wparam(1);
|
||||
$bp=&wparam(2);
|
||||
$count=&wparam(3);
|
||||
|
||||
&function_begin($name,"");
|
||||
|
||||
&comment("");
|
||||
&sub($count,4,$count);
|
||||
&mov("zero",$cc);
|
||||
&br(&label("finish"));
|
||||
&blt($count,&label("finish"));
|
||||
|
||||
($a0,$b0)=&NR(2);
|
||||
&ld($a0,&QWPw(0,$ap));
|
||||
&ld($b0,&QWPw(0,$bp));
|
||||
|
||||
##########################################################
|
||||
&set_label("loop");
|
||||
|
||||
($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
|
||||
($b1)=&NR(1); &ld($b1,&QWPw(1,$bp));
|
||||
($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
|
||||
($b2)=&NR(1); &ld($b2,&QWPw(2,$bp));
|
||||
($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
|
||||
($b3)=&NR(1); &ld($b3,&QWPw(3,$bp));
|
||||
|
||||
($o0,$t0)=&NR(2);
|
||||
&add($a0,$b0,$o0);
|
||||
&cmpult($o0,$b0,$t0);
|
||||
&add($o0,$cc,$o0);
|
||||
&cmpult($o0,$cc,$cc);
|
||||
&add($cc,$t0,$cc); &FR($t0);
|
||||
|
||||
($t1,$o1)=&NR(2);
|
||||
|
||||
&add($a1,$b1,$o1); &FR($a1);
|
||||
&cmpult($o1,$b1,$t1); &FR($b1);
|
||||
&add($o1,$cc,$o1);
|
||||
&cmpult($o1,$cc,$cc);
|
||||
&add($cc,$t1,$cc); &FR($t1);
|
||||
|
||||
($t2,$o2)=&NR(2);
|
||||
|
||||
&add($a2,$b2,$o2); &FR($a2);
|
||||
&cmpult($o2,$b2,$t2); &FR($b2);
|
||||
&add($o2,$cc,$o2);
|
||||
&cmpult($o2,$cc,$cc);
|
||||
&add($cc,$t2,$cc); &FR($t2);
|
||||
|
||||
($t3,$o3)=&NR(2);
|
||||
|
||||
&add($a3,$b3,$o3); &FR($a3);
|
||||
&cmpult($o3,$b3,$t3); &FR($b3);
|
||||
&add($o3,$cc,$o3);
|
||||
&cmpult($o3,$cc,$cc);
|
||||
&add($cc,$t3,$cc); &FR($t3);
|
||||
|
||||
&st($o0,&QWPw(0,$rp)); &FR($o0);
|
||||
&st($o1,&QWPw(0,$rp)); &FR($o1);
|
||||
&st($o2,&QWPw(0,$rp)); &FR($o2);
|
||||
&st($o3,&QWPw(0,$rp)); &FR($o3);
|
||||
|
||||
&sub($count,4,$count); # count-=4
|
||||
&add($ap,4*$QWS,$ap); # count+=4
|
||||
&add($bp,4*$QWS,$bp); # count+=4
|
||||
&add($rp,4*$QWS,$rp); # count+=4
|
||||
|
||||
&blt($count,&label("finish"));
|
||||
&ld($a0,&QWPw(0,$ap));
|
||||
&ld($b0,&QWPw(0,$bp));
|
||||
&br(&label("loop"));
|
||||
##################################################
|
||||
# Do the last 0..3 words
|
||||
|
||||
($t0,$o0)=&NR(2);
|
||||
&set_label("last_loop");
|
||||
|
||||
&ld($a0,&QWPw(0,$ap)); # get a
|
||||
&ld($b0,&QWPw(0,$bp)); # get b
|
||||
|
||||
&add($a0,$b0,$o0);
|
||||
&cmpult($o0,$b0,$t0); # will we borrow?
|
||||
&add($o0,$cc,$o0); # will we borrow?
|
||||
&cmpult($o0,$cc,$cc); # will we borrow?
|
||||
&add($cc,$t0,$cc); # add the borrows
|
||||
&st($o0,&QWPw(0,$rp)); # save
|
||||
|
||||
&add($ap,$QWS,$ap);
|
||||
&add($bp,$QWS,$bp);
|
||||
&add($rp,$QWS,$rp);
|
||||
&sub($count,1,$count);
|
||||
&bgt($count,&label("last_loop"));
|
||||
&function_end_A($name);
|
||||
|
||||
######################################################
|
||||
&set_label("finish");
|
||||
&add($count,4,$count);
|
||||
&bgt($count,&label("last_loop"));
|
||||
|
||||
&FR($o0,$t0,$a0,$b0);
|
||||
&set_label("end");
|
||||
&function_end($name);
|
||||
|
||||
&fin_pool;
|
||||
}
|
||||
|
||||
1;
|
144
crypto/bn/asm/alpha.works/div.pl
Normal file
144
crypto/bn/asm/alpha.works/div.pl
Normal file
@@ -0,0 +1,144 @@
|
||||
#!/usr/local/bin/perl
|
||||
|
||||
sub bn_div64
|
||||
{
|
||||
local($data)=<<'EOF';
|
||||
#
|
||||
# What follows was taken directly from the C compiler with a few
|
||||
# hacks to redo the lables.
|
||||
#
|
||||
.text
|
||||
.set noreorder
|
||||
.set volatile
|
||||
.align 3
|
||||
.globl bn_div64
|
||||
.ent bn_div64
|
||||
bn_div64:
|
||||
ldgp $29,0($27)
|
||||
bn_div64..ng:
|
||||
lda $30,-48($30)
|
||||
.frame $30,48,$26,0
|
||||
stq $26,0($30)
|
||||
stq $9,8($30)
|
||||
stq $10,16($30)
|
||||
stq $11,24($30)
|
||||
stq $12,32($30)
|
||||
stq $13,40($30)
|
||||
.mask 0x4003e00,-48
|
||||
.prologue 1
|
||||
bis $16,$16,$9
|
||||
bis $17,$17,$10
|
||||
bis $18,$18,$11
|
||||
bis $31,$31,$13
|
||||
bis $31,2,$12
|
||||
bne $11,$9119
|
||||
lda $0,-1
|
||||
br $31,$9136
|
||||
.align 4
|
||||
$9119:
|
||||
bis $11,$11,$16
|
||||
jsr $26,BN_num_bits_word
|
||||
ldgp $29,0($26)
|
||||
subq $0,64,$1
|
||||
beq $1,$9120
|
||||
bis $31,1,$1
|
||||
sll $1,$0,$1
|
||||
cmpule $9,$1,$1
|
||||
bne $1,$9120
|
||||
# lda $16,_IO_stderr_
|
||||
# lda $17,$C32
|
||||
# bis $0,$0,$18
|
||||
# jsr $26,fprintf
|
||||
# ldgp $29,0($26)
|
||||
jsr $26,abort
|
||||
ldgp $29,0($26)
|
||||
.align 4
|
||||
$9120:
|
||||
bis $31,64,$3
|
||||
cmpult $9,$11,$2
|
||||
subq $3,$0,$1
|
||||
addl $1,$31,$0
|
||||
subq $9,$11,$1
|
||||
cmoveq $2,$1,$9
|
||||
beq $0,$9122
|
||||
zapnot $0,15,$2
|
||||
subq $3,$0,$1
|
||||
sll $11,$2,$11
|
||||
sll $9,$2,$3
|
||||
srl $10,$1,$1
|
||||
sll $10,$2,$10
|
||||
bis $3,$1,$9
|
||||
$9122:
|
||||
srl $11,32,$5
|
||||
zapnot $11,15,$6
|
||||
lda $7,-1
|
||||
.align 5
|
||||
$9123:
|
||||
srl $9,32,$1
|
||||
subq $1,$5,$1
|
||||
bne $1,$9126
|
||||
zapnot $7,15,$27
|
||||
br $31,$9127
|
||||
.align 4
|
||||
$9126:
|
||||
bis $9,$9,$24
|
||||
bis $5,$5,$25
|
||||
divqu $24,$25,$27
|
||||
$9127:
|
||||
srl $10,32,$4
|
||||
.align 5
|
||||
$9128:
|
||||
mulq $27,$5,$1
|
||||
subq $9,$1,$3
|
||||
zapnot $3,240,$1
|
||||
bne $1,$9129
|
||||
mulq $6,$27,$2
|
||||
sll $3,32,$1
|
||||
addq $1,$4,$1
|
||||
cmpule $2,$1,$2
|
||||
bne $2,$9129
|
||||
subq $27,1,$27
|
||||
br $31,$9128
|
||||
.align 4
|
||||
$9129:
|
||||
mulq $27,$6,$1
|
||||
mulq $27,$5,$4
|
||||
srl $1,32,$3
|
||||
sll $1,32,$1
|
||||
addq $4,$3,$4
|
||||
cmpult $10,$1,$2
|
||||
subq $10,$1,$10
|
||||
addq $2,$4,$2
|
||||
cmpult $9,$2,$1
|
||||
bis $2,$2,$4
|
||||
beq $1,$9134
|
||||
addq $9,$11,$9
|
||||
subq $27,1,$27
|
||||
$9134:
|
||||
subl $12,1,$12
|
||||
subq $9,$4,$9
|
||||
beq $12,$9124
|
||||
sll $27,32,$13
|
||||
sll $9,32,$2
|
||||
srl $10,32,$1
|
||||
sll $10,32,$10
|
||||
bis $2,$1,$9
|
||||
br $31,$9123
|
||||
.align 4
|
||||
$9124:
|
||||
bis $13,$27,$0
|
||||
$9136:
|
||||
ldq $26,0($30)
|
||||
ldq $9,8($30)
|
||||
ldq $10,16($30)
|
||||
ldq $11,24($30)
|
||||
ldq $12,32($30)
|
||||
ldq $13,40($30)
|
||||
addq $30,48,$30
|
||||
ret $31,($26),1
|
||||
.end bn_div64
|
||||
EOF
|
||||
&asm_add($data);
|
||||
}
|
||||
|
||||
1;
|
116
crypto/bn/asm/alpha.works/mul.pl
Normal file
116
crypto/bn/asm/alpha.works/mul.pl
Normal file
@@ -0,0 +1,116 @@
|
||||
#!/usr/local/bin/perl
|
||||
# alpha assember
|
||||
|
||||
sub bn_mul_words
|
||||
{
|
||||
local($name)=@_;
|
||||
local($cc,$a,$b,$r,$couny);
|
||||
|
||||
&init_pool(4);
|
||||
($cc)=GR("r0");
|
||||
|
||||
$rp=&wparam(0);
|
||||
$ap=&wparam(1);
|
||||
$count=&wparam(2);
|
||||
$word=&wparam(3);
|
||||
|
||||
&function_begin($name,"");
|
||||
|
||||
&comment("");
|
||||
&sub($count,4,$count);
|
||||
&mov("zero",$cc);
|
||||
&br(&label("finish"));
|
||||
&blt($count,&label("finish"));
|
||||
|
||||
($a0,$r0)=&NR(2);
|
||||
&ld($a0,&QWPw(0,$ap));
|
||||
&ld($r0,&QWPw(0,$rp));
|
||||
|
||||
$a=<<'EOF';
|
||||
##########################################################
|
||||
&set_label("loop");
|
||||
|
||||
($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
|
||||
($b1)=&NR(1); &ld($b1,&QWPw(1,$bp));
|
||||
($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
|
||||
($b2)=&NR(1); &ld($b2,&QWPw(2,$bp));
|
||||
($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
|
||||
($b3)=&NR(1); &ld($b3,&QWPw(3,$bp));
|
||||
|
||||
($o0,$t0)=&NR(2);
|
||||
&add($a0,$b0,$o0);
|
||||
&cmpult($o0,$b0,$t0);
|
||||
&add($o0,$cc,$o0);
|
||||
&cmpult($o0,$cc,$cc);
|
||||
&add($cc,$t0,$cc); &FR($t0);
|
||||
|
||||
($t1,$o1)=&NR(2);
|
||||
|
||||
&add($a1,$b1,$o1); &FR($a1);
|
||||
&cmpult($o1,$b1,$t1); &FR($b1);
|
||||
&add($o1,$cc,$o1);
|
||||
&cmpult($o1,$cc,$cc);
|
||||
&add($cc,$t1,$cc); &FR($t1);
|
||||
|
||||
($t2,$o2)=&NR(2);
|
||||
|
||||
&add($a2,$b2,$o2); &FR($a2);
|
||||
&cmpult($o2,$b2,$t2); &FR($b2);
|
||||
&add($o2,$cc,$o2);
|
||||
&cmpult($o2,$cc,$cc);
|
||||
&add($cc,$t2,$cc); &FR($t2);
|
||||
|
||||
($t3,$o3)=&NR(2);
|
||||
|
||||
&add($a3,$b3,$o3); &FR($a3);
|
||||
&cmpult($o3,$b3,$t3); &FR($b3);
|
||||
&add($o3,$cc,$o3);
|
||||
&cmpult($o3,$cc,$cc);
|
||||
&add($cc,$t3,$cc); &FR($t3);
|
||||
|
||||
&st($o0,&QWPw(0,$rp)); &FR($o0);
|
||||
&st($o1,&QWPw(0,$rp)); &FR($o1);
|
||||
&st($o2,&QWPw(0,$rp)); &FR($o2);
|
||||
&st($o3,&QWPw(0,$rp)); &FR($o3);
|
||||
|
||||
&sub($count,4,$count); # count-=4
|
||||
&add($ap,4*$QWS,$ap); # count+=4
|
||||
&add($bp,4*$QWS,$bp); # count+=4
|
||||
&add($rp,4*$QWS,$rp); # count+=4
|
||||
|
||||
&blt($count,&label("finish"));
|
||||
&ld($a0,&QWPw(0,$ap));
|
||||
&ld($b0,&QWPw(0,$bp));
|
||||
&br(&label("loop"));
|
||||
EOF
|
||||
##################################################
|
||||
# Do the last 0..3 words
|
||||
|
||||
&set_label("last_loop");
|
||||
|
||||
&ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
|
||||
&mul($a0,$word,($l0)=&NR(1));
|
||||
&add($ap,$QWS,$ap);
|
||||
&muh($a0,$word,($h0)=&NR(1)); &FR($a0);
|
||||
&add($l0,$cc,$l0);
|
||||
&add($rp,$QWS,$rp);
|
||||
&sub($count,1,$count);
|
||||
&cmpult($l0,$cc,$cc);
|
||||
&st($l0,&QWPw(-1,$rp)); &FR($l0);
|
||||
&add($h0,$cc,$cc); &FR($h0);
|
||||
|
||||
&bgt($count,&label("last_loop"));
|
||||
&function_end_A($name);
|
||||
|
||||
######################################################
|
||||
&set_label("finish");
|
||||
&add($count,4,$count);
|
||||
&bgt($count,&label("last_loop"));
|
||||
|
||||
&set_label("end");
|
||||
&function_end($name);
|
||||
|
||||
&fin_pool;
|
||||
}
|
||||
|
||||
1;
|
120
crypto/bn/asm/alpha.works/mul_add.pl
Normal file
120
crypto/bn/asm/alpha.works/mul_add.pl
Normal file
@@ -0,0 +1,120 @@
|
||||
#!/usr/local/bin/perl
|
||||
# alpha assember
|
||||
|
||||
sub bn_mul_add_words
|
||||
{
|
||||
local($name)=@_;
|
||||
local($cc,$a,$b,$r,$couny);
|
||||
|
||||
&init_pool(4);
|
||||
($cc)=GR("r0");
|
||||
|
||||
$rp=&wparam(0);
|
||||
$ap=&wparam(1);
|
||||
$count=&wparam(2);
|
||||
$word=&wparam(3);
|
||||
|
||||
&function_begin($name,"");
|
||||
|
||||
&comment("");
|
||||
&sub($count,4,$count);
|
||||
&mov("zero",$cc);
|
||||
&br(&label("finish"));
|
||||
&blt($count,&label("finish"));
|
||||
|
||||
($a0,$r0)=&NR(2);
|
||||
&ld($a0,&QWPw(0,$ap));
|
||||
&ld($r0,&QWPw(0,$rp));
|
||||
|
||||
$a=<<'EOF';
|
||||
##########################################################
|
||||
&set_label("loop");
|
||||
|
||||
($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
|
||||
($b1)=&NR(1); &ld($b1,&QWPw(1,$bp));
|
||||
($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
|
||||
($b2)=&NR(1); &ld($b2,&QWPw(2,$bp));
|
||||
($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
|
||||
($b3)=&NR(1); &ld($b3,&QWPw(3,$bp));
|
||||
|
||||
($o0,$t0)=&NR(2);
|
||||
&add($a0,$b0,$o0);
|
||||
&cmpult($o0,$b0,$t0);
|
||||
&add($o0,$cc,$o0);
|
||||
&cmpult($o0,$cc,$cc);
|
||||
&add($cc,$t0,$cc); &FR($t0);
|
||||
|
||||
($t1,$o1)=&NR(2);
|
||||
|
||||
&add($a1,$b1,$o1); &FR($a1);
|
||||
&cmpult($o1,$b1,$t1); &FR($b1);
|
||||
&add($o1,$cc,$o1);
|
||||
&cmpult($o1,$cc,$cc);
|
||||
&add($cc,$t1,$cc); &FR($t1);
|
||||
|
||||
($t2,$o2)=&NR(2);
|
||||
|
||||
&add($a2,$b2,$o2); &FR($a2);
|
||||
&cmpult($o2,$b2,$t2); &FR($b2);
|
||||
&add($o2,$cc,$o2);
|
||||
&cmpult($o2,$cc,$cc);
|
||||
&add($cc,$t2,$cc); &FR($t2);
|
||||
|
||||
($t3,$o3)=&NR(2);
|
||||
|
||||
&add($a3,$b3,$o3); &FR($a3);
|
||||
&cmpult($o3,$b3,$t3); &FR($b3);
|
||||
&add($o3,$cc,$o3);
|
||||
&cmpult($o3,$cc,$cc);
|
||||
&add($cc,$t3,$cc); &FR($t3);
|
||||
|
||||
&st($o0,&QWPw(0,$rp)); &FR($o0);
|
||||
&st($o1,&QWPw(0,$rp)); &FR($o1);
|
||||
&st($o2,&QWPw(0,$rp)); &FR($o2);
|
||||
&st($o3,&QWPw(0,$rp)); &FR($o3);
|
||||
|
||||
&sub($count,4,$count); # count-=4
|
||||
&add($ap,4*$QWS,$ap); # count+=4
|
||||
&add($bp,4*$QWS,$bp); # count+=4
|
||||
&add($rp,4*$QWS,$rp); # count+=4
|
||||
|
||||
&blt($count,&label("finish"));
|
||||
&ld($a0,&QWPw(0,$ap));
|
||||
&ld($b0,&QWPw(0,$bp));
|
||||
&br(&label("loop"));
|
||||
EOF
|
||||
##################################################
|
||||
# Do the last 0..3 words
|
||||
|
||||
&set_label("last_loop");
|
||||
|
||||
&ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
|
||||
&ld(($r0)=&NR(1),&QWPw(0,$rp)); # get b
|
||||
&mul($a0,$word,($l0)=&NR(1));
|
||||
&sub($count,1,$count);
|
||||
&add($ap,$QWS,$ap);
|
||||
&muh($a0,$word,($h0)=&NR(1)); &FR($a0);
|
||||
&add($r0,$l0,$r0);
|
||||
&add($rp,$QWS,$rp);
|
||||
&cmpult($r0,$l0,($t0)=&NR(1)); &FR($l0);
|
||||
&add($r0,$cc,$r0);
|
||||
&add($h0,$t0,$h0); &FR($t0);
|
||||
&cmpult($r0,$cc,$cc);
|
||||
&st($r0,&QWPw(-1,$rp)); &FR($r0);
|
||||
&add($h0,$cc,$cc); &FR($h0);
|
||||
|
||||
&bgt($count,&label("last_loop"));
|
||||
&function_end_A($name);
|
||||
|
||||
######################################################
|
||||
&set_label("finish");
|
||||
&add($count,4,$count);
|
||||
&bgt($count,&label("last_loop"));
|
||||
|
||||
&set_label("end");
|
||||
&function_end($name);
|
||||
|
||||
&fin_pool;
|
||||
}
|
||||
|
||||
1;
|
213
crypto/bn/asm/alpha.works/mul_c4.pl
Normal file
213
crypto/bn/asm/alpha.works/mul_c4.pl
Normal file
@@ -0,0 +1,213 @@
|
||||
#!/usr/local/bin/perl
|
||||
# alpha assember
|
||||
|
||||
sub mul_add_c
|
||||
{
|
||||
local($a,$b,$c0,$c1,$c2)=@_;
|
||||
local($l1,$h1,$t1,$t2);
|
||||
|
||||
&mul($a,$b,($l1)=&NR(1));
|
||||
&muh($a,$b,($h1)=&NR(1));
|
||||
&add($c0,$l1,$c0);
|
||||
&cmpult($c0,$l1,($t1)=&NR(1)); &FR($l1);
|
||||
&add($t1,$h1,$h1); &FR($t1);
|
||||
&add($c1,$h1,$c1);
|
||||
&cmpult($c1,$h1,($t2)=&NR(1)); &FR($h1);
|
||||
&add($c2,$t2,$c2); &FR($t2);
|
||||
}
|
||||
|
||||
sub bn_mul_comba4
|
||||
{
|
||||
local($name)=@_;
|
||||
local(@a,@b,$r,$c0,$c1,$c2);
|
||||
|
||||
$cnt=1;
|
||||
&init_pool(3);
|
||||
|
||||
$rp=&wparam(0);
|
||||
$ap=&wparam(1);
|
||||
$bp=&wparam(2);
|
||||
|
||||
&function_begin($name,"");
|
||||
|
||||
&comment("");
|
||||
|
||||
&ld(($a[0])=&NR(1),&QWPw(0,$ap));
|
||||
&ld(($b[0])=&NR(1),&QWPw(0,$bp));
|
||||
&ld(($a[1])=&NR(1),&QWPw(1,$ap));
|
||||
&ld(($b[1])=&NR(1),&QWPw(1,$bp));
|
||||
&mul($a[0],$b[0],($r00)=&NR(1));
|
||||
&ld(($a[2])=&NR(1),&QWPw(2,$ap));
|
||||
&ld(($b[2])=&NR(1),&QWPw(2,$bp));
|
||||
&muh($a[0],$b[0],($r01)=&NR(1));
|
||||
&FR($ap); &ld(($a[3])=&NR(1),&QWPw(3,$ap));
|
||||
&FR($bp); &ld(($b[3])=&NR(1),&QWPw(3,$bp));
|
||||
&mul($a[0],$b[1],($r02)=&NR(1));
|
||||
|
||||
($R,$H1,$H2)=&NR(3);
|
||||
|
||||
&st($r00,&QWPw(0,$rp)); &FR($r00);
|
||||
|
||||
&mov("zero",$R);
|
||||
&mul($a[1],$b[0],($r03)=&NR(1));
|
||||
|
||||
&mov("zero",$H1);
|
||||
&mov("zero",$H0);
|
||||
&add($R,$r01,$R);
|
||||
&muh($a[0],$b[1],($r04)=&NR(1));
|
||||
&cmpult($R,$r01,($t01)=&NR(1)); &FR($r01);
|
||||
&add($R,$r02,$R);
|
||||
&add($H1,$t01,$H1) &FR($t01);
|
||||
&muh($a[1],$b[0],($r05)=&NR(1));
|
||||
&cmpult($R,$r02,($t02)=&NR(1)); &FR($r02);
|
||||
&add($R,$r03,$R);
|
||||
&add($H2,$t02,$H2) &FR($t02);
|
||||
&mul($a[0],$b[2],($r06)=&NR(1));
|
||||
&cmpult($R,$r03,($t03)=&NR(1)); &FR($r03);
|
||||
&add($H1,$t03,$H1) &FR($t03);
|
||||
&st($R,&QWPw(1,$rp));
|
||||
&add($H1,$H2,$R);
|
||||
|
||||
&mov("zero",$H1);
|
||||
&add($R,$r04,$R);
|
||||
&mov("zero",$H2);
|
||||
&mul($a[1],$b[1],($r07)=&NR(1));
|
||||
&cmpult($R,$r04,($t04)=&NR(1)); &FR($r04);
|
||||
&add($R,$r05,$R);
|
||||
&add($H1,$t04,$H1) &FR($t04);
|
||||
&mul($a[2],$b[0],($r08)=&NR(1));
|
||||
&cmpult($R,$r05,($t05)=&NR(1)); &FR($r05);
|
||||
&add($R,$r01,$R);
|
||||
&add($H2,$t05,$H2) &FR($t05);
|
||||
&muh($a[0],$b[2],($r09)=&NR(1));
|
||||
&cmpult($R,$r06,($t06)=&NR(1)); &FR($r06);
|
||||
&add($R,$r07,$R);
|
||||
&add($H1,$t06,$H1) &FR($t06);
|
||||
&muh($a[1],$b[1],($r10)=&NR(1));
|
||||
&cmpult($R,$r07,($t07)=&NR(1)); &FR($r07);
|
||||
&add($R,$r08,$R);
|
||||
&add($H2,$t07,$H2) &FR($t07);
|
||||
&muh($a[2],$b[0],($r11)=&NR(1));
|
||||
&cmpult($R,$r08,($t08)=&NR(1)); &FR($r08);
|
||||
&add($H1,$t08,$H1) &FR($t08);
|
||||
&st($R,&QWPw(2,$rp));
|
||||
&add($H1,$H2,$R);
|
||||
|
||||
&mov("zero",$H1);
|
||||
&add($R,$r09,$R);
|
||||
&mov("zero",$H2);
|
||||
&mul($a[0],$b[3],($r12)=&NR(1));
|
||||
&cmpult($R,$r09,($t09)=&NR(1)); &FR($r09);
|
||||
&add($R,$r10,$R);
|
||||
&add($H1,$t09,$H1) &FR($t09);
|
||||
&mul($a[1],$b[2],($r13)=&NR(1));
|
||||
&cmpult($R,$r10,($t10)=&NR(1)); &FR($r10);
|
||||
&add($R,$r11,$R);
|
||||
&add($H1,$t10,$H1) &FR($t10);
|
||||
&mul($a[2],$b[1],($r14)=&NR(1));
|
||||
&cmpult($R,$r11,($t11)=&NR(1)); &FR($r11);
|
||||
&add($R,$r12,$R);
|
||||
&add($H1,$t11,$H1) &FR($t11);
|
||||
&mul($a[3],$b[0],($r15)=&NR(1));
|
||||
&cmpult($R,$r12,($t12)=&NR(1)); &FR($r12);
|
||||
&add($R,$r13,$R);
|
||||
&add($H1,$t12,$H1) &FR($t12);
|
||||
&muh($a[0],$b[3],($r16)=&NR(1));
|
||||
&cmpult($R,$r13,($t13)=&NR(1)); &FR($r13);
|
||||
&add($R,$r14,$R);
|
||||
&add($H1,$t13,$H1) &FR($t13);
|
||||
&muh($a[1],$b[2],($r17)=&NR(1));
|
||||
&cmpult($R,$r14,($t14)=&NR(1)); &FR($r14);
|
||||
&add($R,$r15,$R);
|
||||
&add($H1,$t14,$H1) &FR($t14);
|
||||
&muh($a[2],$b[1],($r18)=&NR(1));
|
||||
&cmpult($R,$r15,($t15)=&NR(1)); &FR($r15);
|
||||
&add($H1,$t15,$H1) &FR($t15);
|
||||
&st($R,&QWPw(3,$rp));
|
||||
&add($H1,$H2,$R);
|
||||
|
||||
&mov("zero",$H1);
|
||||
&add($R,$r16,$R);
|
||||
&mov("zero",$H2);
|
||||
&muh($a[3],$b[0],($r19)=&NR(1));
|
||||
&cmpult($R,$r16,($t16)=&NR(1)); &FR($r16);
|
||||
&add($R,$r17,$R);
|
||||
&add($H1,$t16,$H1) &FR($t16);
|
||||
&mul($a[1],$b[3],($r20)=&NR(1));
|
||||
&cmpult($R,$r17,($t17)=&NR(1)); &FR($r17);
|
||||
&add($R,$r18,$R);
|
||||
&add($H1,$t17,$H1) &FR($t17);
|
||||
&mul($a[2],$b[2],($r21)=&NR(1));
|
||||
&cmpult($R,$r18,($t18)=&NR(1)); &FR($r18);
|
||||
&add($R,$r19,$R);
|
||||
&add($H1,$t18,$H1) &FR($t18);
|
||||
&mul($a[3],$b[1],($r22)=&NR(1));
|
||||
&cmpult($R,$r19,($t19)=&NR(1)); &FR($r19);
|
||||
&add($R,$r20,$R);
|
||||
&add($H1,$t19,$H1) &FR($t19);
|
||||
&muh($a[1],$b[3],($r23)=&NR(1));
|
||||
&cmpult($R,$r20,($t20)=&NR(1)); &FR($r20);
|
||||
&add($R,$r21,$R);
|
||||
&add($H1,$t20,$H1) &FR($t20);
|
||||
&muh($a[2],$b[2],($r24)=&NR(1));
|
||||
&cmpult($R,$r21,($t21)=&NR(1)); &FR($r21);
|
||||
&add($R,$r22,$R);
|
||||
&add($H1,$t21,$H1) &FR($t21);
|
||||
&muh($a[3],$b[1],($r25)=&NR(1));
|
||||
&cmpult($R,$r22,($t22)=&NR(1)); &FR($r22);
|
||||
&add($H1,$t22,$H1) &FR($t22);
|
||||
&st($R,&QWPw(4,$rp));
|
||||
&add($H1,$H2,$R);
|
||||
|
||||
&mov("zero",$H1);
|
||||
&add($R,$r23,$R);
|
||||
&mov("zero",$H2);
|
||||
&mul($a[2],$b[3],($r26)=&NR(1));
|
||||
&cmpult($R,$r23,($t23)=&NR(1)); &FR($r23);
|
||||
&add($R,$r24,$R);
|
||||
&add($H1,$t23,$H1) &FR($t23);
|
||||
&mul($a[3],$b[2],($r27)=&NR(1));
|
||||
&cmpult($R,$r24,($t24)=&NR(1)); &FR($r24);
|
||||
&add($R,$r25,$R);
|
||||
&add($H1,$t24,$H1) &FR($t24);
|
||||
&muh($a[2],$b[3],($r28)=&NR(1));
|
||||
&cmpult($R,$r25,($t25)=&NR(1)); &FR($r25);
|
||||
&add($R,$r26,$R);
|
||||
&add($H1,$t25,$H1) &FR($t25);
|
||||
&muh($a[3],$b[2],($r29)=&NR(1));
|
||||
&cmpult($R,$r26,($t26)=&NR(1)); &FR($r26);
|
||||
&add($R,$r27,$R);
|
||||
&add($H1,$t26,$H1) &FR($t26);
|
||||
&mul($a[3],$b[3],($r30)=&NR(1));
|
||||
&cmpult($R,$r27,($t27)=&NR(1)); &FR($r27);
|
||||
&add($H1,$t27,$H1) &FR($t27);
|
||||
&st($R,&QWPw(5,$rp));
|
||||
&add($H1,$H2,$R);
|
||||
|
||||
&mov("zero",$H1);
|
||||
&add($R,$r28,$R);
|
||||
&mov("zero",$H2);
|
||||
&muh($a[3],$b[3],($r31)=&NR(1));
|
||||
&cmpult($R,$r28,($t28)=&NR(1)); &FR($r28);
|
||||
&add($R,$r29,$R);
|
||||
&add($H1,$t28,$H1) &FR($t28);
|
||||
############
|
||||
&cmpult($R,$r29,($t29)=&NR(1)); &FR($r29);
|
||||
&add($R,$r30,$R);
|
||||
&add($H1,$t29,$H1) &FR($t29);
|
||||
############
|
||||
&cmpult($R,$r30,($t30)=&NR(1)); &FR($r30);
|
||||
&add($H1,$t30,$H1) &FR($t30);
|
||||
&st($R,&QWPw(6,$rp));
|
||||
&add($H1,$H2,$R);
|
||||
|
||||
&add($R,$r31,$R); &FR($r31);
|
||||
&st($R,&QWPw(7,$rp));
|
||||
|
||||
&FR($R,$H1,$H2);
|
||||
&function_end($name);
|
||||
|
||||
&fin_pool;
|
||||
}
|
||||
|
||||
1;
|
98
crypto/bn/asm/alpha.works/mul_c4.works.pl
Normal file
98
crypto/bn/asm/alpha.works/mul_c4.works.pl
Normal file
@@ -0,0 +1,98 @@
|
||||
#!/usr/local/bin/perl
|
||||
# alpha assember
|
||||
|
||||
sub mul_add_c
|
||||
{
|
||||
local($a,$b,$c0,$c1,$c2)=@_;
|
||||
local($l1,$h1,$t1,$t2);
|
||||
|
||||
print STDERR "count=$cnt\n"; $cnt++;
|
||||
&mul($a,$b,($l1)=&NR(1));
|
||||
&muh($a,$b,($h1)=&NR(1));
|
||||
&add($c0,$l1,$c0);
|
||||
&cmpult($c0,$l1,($t1)=&NR(1)); &FR($l1);
|
||||
&add($t1,$h1,$h1); &FR($t1);
|
||||
&add($c1,$h1,$c1);
|
||||
&cmpult($c1,$h1,($t2)=&NR(1)); &FR($h1);
|
||||
&add($c2,$t2,$c2); &FR($t2);
|
||||
}
|
||||
|
||||
sub bn_mul_comba4
|
||||
{
|
||||
local($name)=@_;
|
||||
local(@a,@b,$r,$c0,$c1,$c2);
|
||||
|
||||
$cnt=1;
|
||||
&init_pool(3);
|
||||
|
||||
$rp=&wparam(0);
|
||||
$ap=&wparam(1);
|
||||
$bp=&wparam(2);
|
||||
|
||||
&function_begin($name,"");
|
||||
|
||||
&comment("");
|
||||
|
||||
&ld(($a[0])=&NR(1),&QWPw(0,$ap));
|
||||
&ld(($b[0])=&NR(1),&QWPw(0,$bp));
|
||||
&ld(($a[1])=&NR(1),&QWPw(1,$ap));
|
||||
&ld(($b[1])=&NR(1),&QWPw(1,$bp));
|
||||
&ld(($a[2])=&NR(1),&QWPw(2,$ap));
|
||||
&ld(($b[2])=&NR(1),&QWPw(2,$bp));
|
||||
&ld(($a[3])=&NR(1),&QWPw(3,$ap)); &FR($ap);
|
||||
&ld(($b[3])=&NR(1),&QWPw(3,$bp)); &FR($bp);
|
||||
|
||||
($c0,$c1,$c2)=&NR(3);
|
||||
&mov("zero",$c2);
|
||||
&mul($a[0],$b[0],$c0);
|
||||
&muh($a[0],$b[0],$c1);
|
||||
&st($c0,&QWPw(0,$rp)); &FR($c0); ($c0)=&NR($c0);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[0],$b[1],$c0,$c1,$c2);
|
||||
&mul_add_c($a[1],$b[0],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(1,$rp)); &FR($c0); ($c0)=&NR($c0);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[1],$b[1],$c0,$c1,$c2);
|
||||
&mul_add_c($a[0],$b[2],$c0,$c1,$c2);
|
||||
&mul_add_c($a[2],$b[0],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(2,$rp)); &FR($c0); ($c0)=&NR($c0);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[0],$b[3],$c0,$c1,$c2); &FR($a[0]);
|
||||
&mul_add_c($a[1],$b[2],$c0,$c1,$c2);
|
||||
&mul_add_c($a[2],$b[1],$c0,$c1,$c2);
|
||||
&mul_add_c($a[3],$b[0],$c0,$c1,$c2); &FR($b[0]);
|
||||
&st($c0,&QWPw(3,$rp)); &FR($c0); ($c0)=&NR($c0);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[1],$b[3],$c0,$c1,$c2); &FR($a[1]);
|
||||
&mul_add_c($a[2],$b[2],$c0,$c1,$c2);
|
||||
&mul_add_c($a[3],$b[1],$c0,$c1,$c2); &FR($b[1]);
|
||||
&st($c0,&QWPw(4,$rp)); &FR($c0); ($c0)=&NR($c0);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[2],$b[3],$c0,$c1,$c2); &FR($a[2]);
|
||||
&mul_add_c($a[3],$b[2],$c0,$c1,$c2); &FR($b[2]);
|
||||
&st($c0,&QWPw(5,$rp)); &FR($c0); ($c0)=&NR($c0);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[3],$b[3],$c0,$c1,$c2); &FR($a[3],$b[3]);
|
||||
&st($c0,&QWPw(6,$rp));
|
||||
&st($c1,&QWPw(7,$rp));
|
||||
|
||||
&FR($c0,$c1,$c2);
|
||||
|
||||
&function_end($name);
|
||||
|
||||
&fin_pool;
|
||||
}
|
||||
|
||||
1;
|
177
crypto/bn/asm/alpha.works/mul_c8.pl
Normal file
177
crypto/bn/asm/alpha.works/mul_c8.pl
Normal file
@@ -0,0 +1,177 @@
|
||||
#!/usr/local/bin/perl
|
||||
# alpha assember
|
||||
|
||||
sub bn_mul_comba8
|
||||
{
|
||||
local($name)=@_;
|
||||
local(@a,@b,$r,$c0,$c1,$c2);
|
||||
|
||||
$cnt=1;
|
||||
&init_pool(3);
|
||||
|
||||
$rp=&wparam(0);
|
||||
$ap=&wparam(1);
|
||||
$bp=&wparam(2);
|
||||
|
||||
&function_begin($name,"");
|
||||
|
||||
&comment("");
|
||||
|
||||
&stack_push(2);
|
||||
&ld(($a[0])=&NR(1),&QWPw(0,$ap));
|
||||
&ld(($b[0])=&NR(1),&QWPw(0,$bp));
|
||||
&st($reg_s0,&swtmp(0)); &FR($reg_s0);
|
||||
&st($reg_s1,&swtmp(1)); &FR($reg_s1);
|
||||
&ld(($a[1])=&NR(1),&QWPw(1,$ap));
|
||||
&ld(($b[1])=&NR(1),&QWPw(1,$bp));
|
||||
&ld(($a[2])=&NR(1),&QWPw(2,$ap));
|
||||
&ld(($b[2])=&NR(1),&QWPw(2,$bp));
|
||||
&ld(($a[3])=&NR(1),&QWPw(3,$ap));
|
||||
&ld(($b[3])=&NR(1),&QWPw(3,$bp));
|
||||
&ld(($a[4])=&NR(1),&QWPw(1,$ap));
|
||||
&ld(($b[4])=&NR(1),&QWPw(1,$bp));
|
||||
&ld(($a[5])=&NR(1),&QWPw(1,$ap));
|
||||
&ld(($b[5])=&NR(1),&QWPw(1,$bp));
|
||||
&ld(($a[6])=&NR(1),&QWPw(1,$ap));
|
||||
&ld(($b[6])=&NR(1),&QWPw(1,$bp));
|
||||
&ld(($a[7])=&NR(1),&QWPw(1,$ap)); &FR($ap);
|
||||
&ld(($b[7])=&NR(1),&QWPw(1,$bp)); &FR($bp);
|
||||
|
||||
($c0,$c1,$c2)=&NR(3);
|
||||
&mov("zero",$c2);
|
||||
&mul($a[0],$b[0],$c0);
|
||||
&muh($a[0],$b[0],$c1);
|
||||
&st($c0,&QWPw(0,$rp)); &FR($c0); ($c0)=&NR(1);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[0],$b[1],$c0,$c1,$c2);
|
||||
&mul_add_c($a[1],$b[0],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(1,$rp)); &FR($c0); ($c0)=&NR(1);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[0],$b[2],$c0,$c1,$c2);
|
||||
&mul_add_c($a[1],$b[1],$c0,$c1,$c2);
|
||||
&mul_add_c($a[2],$b[0],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(2,$rp)); &FR($c0); ($c0)=&NR(1);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[0],$b[3],$c0,$c1,$c2);
|
||||
&mul_add_c($a[1],$b[2],$c0,$c1,$c2);
|
||||
&mul_add_c($a[2],$b[1],$c0,$c1,$c2);
|
||||
&mul_add_c($a[3],$b[0],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(3,$rp)); &FR($c0); ($c0)=&NR(1);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[0],$b[4],$c0,$c1,$c2);
|
||||
&mul_add_c($a[1],$b[3],$c0,$c1,$c2);
|
||||
&mul_add_c($a[2],$b[2],$c0,$c1,$c2);
|
||||
&mul_add_c($a[3],$b[1],$c0,$c1,$c2);
|
||||
&mul_add_c($a[4],$b[0],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(4,$rp)); &FR($c0); ($c0)=&NR(1);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[0],$b[5],$c0,$c1,$c2);
|
||||
&mul_add_c($a[1],$b[4],$c0,$c1,$c2);
|
||||
&mul_add_c($a[2],$b[3],$c0,$c1,$c2);
|
||||
&mul_add_c($a[3],$b[2],$c0,$c1,$c2);
|
||||
&mul_add_c($a[4],$b[1],$c0,$c1,$c2);
|
||||
&mul_add_c($a[5],$b[0],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(5,$rp)); &FR($c0); ($c0)=&NR(1);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[0],$b[6],$c0,$c1,$c2);
|
||||
&mul_add_c($a[1],$b[5],$c0,$c1,$c2);
|
||||
&mul_add_c($a[2],$b[4],$c0,$c1,$c2);
|
||||
&mul_add_c($a[3],$b[3],$c0,$c1,$c2);
|
||||
&mul_add_c($a[4],$b[2],$c0,$c1,$c2);
|
||||
&mul_add_c($a[5],$b[1],$c0,$c1,$c2);
|
||||
&mul_add_c($a[6],$b[0],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(6,$rp)); &FR($c0); ($c0)=&NR(1);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[0],$b[7],$c0,$c1,$c2); &FR($a[0]);
|
||||
&mul_add_c($a[1],$b[6],$c0,$c1,$c2);
|
||||
&mul_add_c($a[2],$b[5],$c0,$c1,$c2);
|
||||
&mul_add_c($a[3],$b[4],$c0,$c1,$c2);
|
||||
&mul_add_c($a[4],$b[3],$c0,$c1,$c2);
|
||||
&mul_add_c($a[5],$b[2],$c0,$c1,$c2);
|
||||
&mul_add_c($a[6],$b[1],$c0,$c1,$c2);
|
||||
&mul_add_c($a[7],$b[0],$c0,$c1,$c2); &FR($b[0]);
|
||||
&st($c0,&QWPw(7,$rp)); &FR($c0); ($c0)=&NR(1);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[1],$b[7],$c0,$c1,$c2); &FR($a[1]);
|
||||
&mul_add_c($a[2],$b[6],$c0,$c1,$c2);
|
||||
&mul_add_c($a[3],$b[5],$c0,$c1,$c2);
|
||||
&mul_add_c($a[4],$b[4],$c0,$c1,$c2);
|
||||
&mul_add_c($a[5],$b[3],$c0,$c1,$c2);
|
||||
&mul_add_c($a[6],$b[2],$c0,$c1,$c2);
|
||||
&mul_add_c($a[7],$b[1],$c0,$c1,$c2); &FR($b[1]);
|
||||
&st($c0,&QWPw(8,$rp)); &FR($c0); ($c0)=&NR(1);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[2],$b[7],$c0,$c1,$c2); &FR($a[2]);
|
||||
&mul_add_c($a[3],$b[6],$c0,$c1,$c2);
|
||||
&mul_add_c($a[4],$b[5],$c0,$c1,$c2);
|
||||
&mul_add_c($a[5],$b[4],$c0,$c1,$c2);
|
||||
&mul_add_c($a[6],$b[3],$c0,$c1,$c2);
|
||||
&mul_add_c($a[7],$b[2],$c0,$c1,$c2); &FR($b[2]);
|
||||
&st($c0,&QWPw(9,$rp)); &FR($c0); ($c0)=&NR(1);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[3],$b[7],$c0,$c1,$c2); &FR($a[3]);
|
||||
&mul_add_c($a[4],$b[6],$c0,$c1,$c2);
|
||||
&mul_add_c($a[5],$b[5],$c0,$c1,$c2);
|
||||
&mul_add_c($a[6],$b[4],$c0,$c1,$c2);
|
||||
&mul_add_c($a[7],$b[3],$c0,$c1,$c2); &FR($b[3]);
|
||||
&st($c0,&QWPw(10,$rp)); &FR($c0); ($c0)=&NR(1);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[4],$b[7],$c0,$c1,$c2); &FR($a[4]);
|
||||
&mul_add_c($a[5],$b[6],$c0,$c1,$c2);
|
||||
&mul_add_c($a[6],$b[5],$c0,$c1,$c2);
|
||||
&mul_add_c($a[7],$b[4],$c0,$c1,$c2); &FR($b[4]);
|
||||
&st($c0,&QWPw(11,$rp)); &FR($c0); ($c0)=&NR(1);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[5],$b[7],$c0,$c1,$c2); &FR($a[5]);
|
||||
&mul_add_c($a[6],$b[6],$c0,$c1,$c2);
|
||||
&mul_add_c($a[7],$b[5],$c0,$c1,$c2); &FR($b[5]);
|
||||
&st($c0,&QWPw(12,$rp)); &FR($c0); ($c0)=&NR(1);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[6],$b[7],$c0,$c1,$c2); &FR($a[6]);
|
||||
&mul_add_c($a[7],$b[6],$c0,$c1,$c2); &FR($b[6]);
|
||||
&st($c0,&QWPw(13,$rp)); &FR($c0); ($c0)=&NR(1);
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&mul_add_c($a[7],$b[7],$c0,$c1,$c2); &FR($a[7],$b[7]);
|
||||
&st($c0,&QWPw(14,$rp));
|
||||
&st($c1,&QWPw(15,$rp));
|
||||
|
||||
&FR($c0,$c1,$c2);
|
||||
|
||||
&ld($reg_s0,&swtmp(0));
|
||||
&ld($reg_s1,&swtmp(1));
|
||||
&stack_pop(2);
|
||||
|
||||
&function_end($name);
|
||||
|
||||
&fin_pool;
|
||||
}
|
||||
|
||||
1;
|
113
crypto/bn/asm/alpha.works/sqr.pl
Normal file
113
crypto/bn/asm/alpha.works/sqr.pl
Normal file
@@ -0,0 +1,113 @@
|
||||
#!/usr/local/bin/perl
|
||||
# alpha assember
|
||||
|
||||
sub bn_sqr_words
|
||||
{
|
||||
local($name)=@_;
|
||||
local($cc,$a,$b,$r,$couny);
|
||||
|
||||
&init_pool(3);
|
||||
($cc)=GR("r0");
|
||||
|
||||
$rp=&wparam(0);
|
||||
$ap=&wparam(1);
|
||||
$count=&wparam(2);
|
||||
|
||||
&function_begin($name,"");
|
||||
|
||||
&comment("");
|
||||
&sub($count,4,$count);
|
||||
&mov("zero",$cc);
|
||||
&br(&label("finish"));
|
||||
&blt($count,&label("finish"));
|
||||
|
||||
($a0,$r0)=&NR(2);
|
||||
&ld($a0,&QWPw(0,$ap));
|
||||
&ld($r0,&QWPw(0,$rp));
|
||||
|
||||
$a=<<'EOF';
|
||||
##########################################################
|
||||
&set_label("loop");
|
||||
|
||||
($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
|
||||
($b1)=&NR(1); &ld($b1,&QWPw(1,$bp));
|
||||
($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
|
||||
($b2)=&NR(1); &ld($b2,&QWPw(2,$bp));
|
||||
($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
|
||||
($b3)=&NR(1); &ld($b3,&QWPw(3,$bp));
|
||||
|
||||
($o0,$t0)=&NR(2);
|
||||
&add($a0,$b0,$o0);
|
||||
&cmpult($o0,$b0,$t0);
|
||||
&add($o0,$cc,$o0);
|
||||
&cmpult($o0,$cc,$cc);
|
||||
&add($cc,$t0,$cc); &FR($t0);
|
||||
|
||||
($t1,$o1)=&NR(2);
|
||||
|
||||
&add($a1,$b1,$o1); &FR($a1);
|
||||
&cmpult($o1,$b1,$t1); &FR($b1);
|
||||
&add($o1,$cc,$o1);
|
||||
&cmpult($o1,$cc,$cc);
|
||||
&add($cc,$t1,$cc); &FR($t1);
|
||||
|
||||
($t2,$o2)=&NR(2);
|
||||
|
||||
&add($a2,$b2,$o2); &FR($a2);
|
||||
&cmpult($o2,$b2,$t2); &FR($b2);
|
||||
&add($o2,$cc,$o2);
|
||||
&cmpult($o2,$cc,$cc);
|
||||
&add($cc,$t2,$cc); &FR($t2);
|
||||
|
||||
($t3,$o3)=&NR(2);
|
||||
|
||||
&add($a3,$b3,$o3); &FR($a3);
|
||||
&cmpult($o3,$b3,$t3); &FR($b3);
|
||||
&add($o3,$cc,$o3);
|
||||
&cmpult($o3,$cc,$cc);
|
||||
&add($cc,$t3,$cc); &FR($t3);
|
||||
|
||||
&st($o0,&QWPw(0,$rp)); &FR($o0);
|
||||
&st($o1,&QWPw(0,$rp)); &FR($o1);
|
||||
&st($o2,&QWPw(0,$rp)); &FR($o2);
|
||||
&st($o3,&QWPw(0,$rp)); &FR($o3);
|
||||
|
||||
&sub($count,4,$count); # count-=4
|
||||
&add($ap,4*$QWS,$ap); # count+=4
|
||||
&add($bp,4*$QWS,$bp); # count+=4
|
||||
&add($rp,4*$QWS,$rp); # count+=4
|
||||
|
||||
&blt($count,&label("finish"));
|
||||
&ld($a0,&QWPw(0,$ap));
|
||||
&ld($b0,&QWPw(0,$bp));
|
||||
&br(&label("loop"));
|
||||
EOF
|
||||
##################################################
|
||||
# Do the last 0..3 words
|
||||
|
||||
&set_label("last_loop");
|
||||
|
||||
&ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
|
||||
&mul($a0,$a0,($l0)=&NR(1));
|
||||
&add($ap,$QWS,$ap);
|
||||
&add($rp,2*$QWS,$rp);
|
||||
&sub($count,1,$count);
|
||||
&muh($a0,$a0,($h0)=&NR(1)); &FR($a0);
|
||||
&st($l0,&QWPw(-2,$rp)); &FR($l0);
|
||||
&st($h0,&QWPw(-1,$rp)); &FR($h0);
|
||||
|
||||
&bgt($count,&label("last_loop"));
|
||||
&function_end_A($name);
|
||||
|
||||
######################################################
|
||||
&set_label("finish");
|
||||
&add($count,4,$count);
|
||||
&bgt($count,&label("last_loop"));
|
||||
|
||||
&set_label("end");
|
||||
&function_end($name);
|
||||
|
||||
&fin_pool;
|
||||
}
|
||||
|
||||
1;
|
109
crypto/bn/asm/alpha.works/sqr_c4.pl
Normal file
109
crypto/bn/asm/alpha.works/sqr_c4.pl
Normal file
@@ -0,0 +1,109 @@
|
||||
#!/usr/local/bin/perl
|
||||
# alpha assember
|
||||
|
||||
sub sqr_add_c
|
||||
{
|
||||
local($a,$c0,$c1,$c2)=@_;
|
||||
local($l1,$h1,$t1,$t2);
|
||||
|
||||
&mul($a,$a,($l1)=&NR(1));
|
||||
&muh($a,$a,($h1)=&NR(1));
|
||||
&add($c0,$l1,$c0);
|
||||
&add($c1,$h1,$c1);
|
||||
&cmpult($c0,$l1,($t1)=&NR(1)); &FR($l1);
|
||||
&cmpult($c1,$h1,($t2)=&NR(1)); &FR($h1);
|
||||
&add($c1,$t1,$c1); &FR($t1);
|
||||
&add($c2,$t2,$c2); &FR($t2);
|
||||
}
|
||||
|
||||
sub sqr_add_c2
|
||||
{
|
||||
local($a,$b,$c0,$c1,$c2)=@_;
|
||||
local($l1,$h1,$t1,$t2);
|
||||
|
||||
&mul($a,$b,($l1)=&NR(1));
|
||||
&muh($a,$b,($h1)=&NR(1));
|
||||
&cmplt($l1,"zero",($lc1)=&NR(1));
|
||||
&cmplt($h1,"zero",($hc1)=&NR(1));
|
||||
&add($l1,$l1,$l1);
|
||||
&add($h1,$h1,$h1);
|
||||
&add($h1,$lc1,$h1); &FR($lc1);
|
||||
&add($c2,$hc1,$c2); &FR($hc1);
|
||||
|
||||
&add($c0,$l1,$c0);
|
||||
&add($c1,$h1,$c1);
|
||||
&cmpult($c0,$l1,($lc1)=&NR(1)); &FR($l1);
|
||||
&cmpult($c1,$h1,($hc1)=&NR(1)); &FR($h1);
|
||||
|
||||
&add($c1,$lc1,$c1); &FR($lc1);
|
||||
&add($c2,$hc1,$c2); &FR($hc1);
|
||||
}
|
||||
|
||||
|
||||
sub bn_sqr_comba4
|
||||
{
|
||||
local($name)=@_;
|
||||
local(@a,@b,$r,$c0,$c1,$c2);
|
||||
|
||||
$cnt=1;
|
||||
&init_pool(2);
|
||||
|
||||
$rp=&wparam(0);
|
||||
$ap=&wparam(1);
|
||||
|
||||
&function_begin($name,"");
|
||||
|
||||
&comment("");
|
||||
|
||||
&ld(($a[0])=&NR(1),&QWPw(0,$ap));
|
||||
&ld(($a[1])=&NR(1),&QWPw(1,$ap));
|
||||
&ld(($a[2])=&NR(1),&QWPw(2,$ap));
|
||||
&ld(($a[3])=&NR(1),&QWPw(3,$ap)); &FR($ap);
|
||||
|
||||
($c0,$c1,$c2)=&NR(3);
|
||||
|
||||
&mov("zero",$c2);
|
||||
&mul($a[0],$a[0],$c0);
|
||||
&muh($a[0],$a[0],$c1);
|
||||
&st($c0,&QWPw(0,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c2($a[0],$a[1],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(1,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c($a[1],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[2],$a[0],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(2,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c2($a[3],$a[0],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[2],$a[1],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(3,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c($a[2],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[3],$a[1],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(4,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c2($a[3],$a[2],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(5,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c($a[3],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(6,$rp));
|
||||
&st($c1,&QWPw(7,$rp));
|
||||
|
||||
&function_end($name);
|
||||
|
||||
&fin_pool;
|
||||
}
|
||||
|
||||
1;
|
132
crypto/bn/asm/alpha.works/sqr_c8.pl
Normal file
132
crypto/bn/asm/alpha.works/sqr_c8.pl
Normal file
@@ -0,0 +1,132 @@
|
||||
#!/usr/local/bin/perl
|
||||
# alpha assember
|
||||
|
||||
sub bn_sqr_comba8
|
||||
{
|
||||
local($name)=@_;
|
||||
local(@a,@b,$r,$c0,$c1,$c2);
|
||||
|
||||
$cnt=1;
|
||||
&init_pool(2);
|
||||
|
||||
$rp=&wparam(0);
|
||||
$ap=&wparam(1);
|
||||
|
||||
&function_begin($name,"");
|
||||
|
||||
&comment("");
|
||||
|
||||
&ld(($a[0])=&NR(1),&QWPw(0,$ap));
|
||||
&ld(($a[1])=&NR(1),&QWPw(1,$ap));
|
||||
&ld(($a[2])=&NR(1),&QWPw(2,$ap));
|
||||
&ld(($a[3])=&NR(1),&QWPw(3,$ap));
|
||||
&ld(($a[4])=&NR(1),&QWPw(4,$ap));
|
||||
&ld(($a[5])=&NR(1),&QWPw(5,$ap));
|
||||
&ld(($a[6])=&NR(1),&QWPw(6,$ap));
|
||||
&ld(($a[7])=&NR(1),&QWPw(7,$ap)); &FR($ap);
|
||||
|
||||
($c0,$c1,$c2)=&NR(3);
|
||||
|
||||
&mov("zero",$c2);
|
||||
&mul($a[0],$a[0],$c0);
|
||||
&muh($a[0],$a[0],$c1);
|
||||
&st($c0,&QWPw(0,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c2($a[1],$a[0],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(1,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c($a[1],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[2],$a[0],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(2,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c2($a[2],$a[1],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[3],$a[0],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(3,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c($a[2],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[3],$a[1],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[4],$a[0],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(4,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c2($a[3],$a[2],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[4],$a[1],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[5],$a[0],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(5,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c($a[3],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[4],$a[2],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[5],$a[1],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[6],$a[0],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(6,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c2($a[4],$a[3],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[5],$a[2],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[6],$a[1],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[7],$a[0],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(7,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c($a[4],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[5],$a[3],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[6],$a[2],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[7],$a[1],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(8,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c2($a[5],$a[4],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[6],$a[3],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[7],$a[2],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(9,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c($a[5],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[6],$a[4],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[7],$a[3],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(10,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c2($a[6],$a[5],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[7],$a[4],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(11,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c($a[6],$c0,$c1,$c2);
|
||||
&sqr_add_c2($a[7],$a[5],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(12,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c2($a[7],$a[6],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(13,$rp));
|
||||
($c0,$c1,$c2)=($c1,$c2,$c0);
|
||||
&mov("zero",$c2);
|
||||
|
||||
&sqr_add_c($a[7],$c0,$c1,$c2);
|
||||
&st($c0,&QWPw(14,$rp));
|
||||
&st($c1,&QWPw(15,$rp));
|
||||
|
||||
&function_end($name);
|
||||
|
||||
&fin_pool;
|
||||
}
|
||||
|
||||
1;
|
108
crypto/bn/asm/alpha.works/sub.pl
Normal file
108
crypto/bn/asm/alpha.works/sub.pl
Normal file
@@ -0,0 +1,108 @@
|
||||
#!/usr/local/bin/perl
|
||||
# alpha assember
|
||||
|
||||
sub bn_sub_words
|
||||
{
|
||||
local($name)=@_;
|
||||
local($cc,$a,$b,$r);
|
||||
|
||||
&init_pool(4);
|
||||
($cc)=GR("r0");
|
||||
|
||||
$rp=&wparam(0);
|
||||
$ap=&wparam(1);
|
||||
$bp=&wparam(2);
|
||||
$count=&wparam(3);
|
||||
|
||||
&function_begin($name,"");
|
||||
|
||||
&comment("");
|
||||
&sub($count,4,$count);
|
||||
&mov("zero",$cc);
|
||||
&blt($count,&label("finish"));
|
||||
|
||||
($a0,$b0)=&NR(2);
|
||||
&ld($a0,&QWPw(0,$ap));
|
||||
&ld($b0,&QWPw(0,$bp));
|
||||
|
||||
##########################################################
|
||||
&set_label("loop");
|
||||
|
||||
($a1,$tmp,$b1,$a2,$b2,$a3,$b3,$o0)=&NR(8);
|
||||
&ld($a1,&QWPw(1,$ap));
|
||||
&cmpult($a0,$b0,$tmp); # will we borrow?
|
||||
&ld($b1,&QWPw(1,$bp));
|
||||
&sub($a0,$b0,$a0); # do the subtract
|
||||
&ld($a2,&QWPw(2,$ap));
|
||||
&cmpult($a0,$cc,$b0); # will we borrow?
|
||||
&ld($b2,&QWPw(2,$bp));
|
||||
&sub($a0,$cc,$o0); # will we borrow?
|
||||
&ld($a3,&QWPw(3,$ap));
|
||||
&add($b0,$tmp,$cc); ($t1,$o1)=&NR(2); &FR($tmp);
|
||||
|
||||
&cmpult($a1,$b1,$t1); # will we borrow?
|
||||
&sub($a1,$b1,$a1); # do the subtract
|
||||
&ld($b3,&QWPw(3,$bp));
|
||||
&cmpult($a1,$cc,$b1); # will we borrow?
|
||||
&sub($a1,$cc,$o1); # will we borrow?
|
||||
&add($b1,$t1,$cc); ($tmp,$o2)=&NR(2); &FR($t1,$a1,$b1);
|
||||
|
||||
&cmpult($a2,$b2,$tmp); # will we borrow?
|
||||
&sub($a2,$b2,$a2); # do the subtract
|
||||
&st($o0,&QWPw(0,$rp)); &FR($o0); # save
|
||||
&cmpult($a2,$cc,$b2); # will we borrow?
|
||||
&sub($a2,$cc,$o2); # will we borrow?
|
||||
&add($b2,$tmp,$cc); ($t3,$o3)=&NR(2); &FR($tmp,$a2,$b2);
|
||||
|
||||
&cmpult($a3,$b3,$t3); # will we borrow?
|
||||
&sub($a3,$b3,$a3); # do the subtract
|
||||
&st($o1,&QWPw(1,$rp)); &FR($o1);
|
||||
&cmpult($a3,$cc,$b3); # will we borrow?
|
||||
&sub($a3,$cc,$o3); # will we borrow?
|
||||
&add($b3,$t3,$cc); &FR($t3,$a3,$b3);
|
||||
|
||||
&st($o2,&QWPw(2,$rp)); &FR($o2);
|
||||
&sub($count,4,$count); # count-=4
|
||||
&st($o3,&QWPw(3,$rp)); &FR($o3);
|
||||
&add($ap,4*$QWS,$ap); # count+=4
|
||||
&add($bp,4*$QWS,$bp); # count+=4
|
||||
&add($rp,4*$QWS,$rp); # count+=4
|
||||
|
||||
&blt($count,&label("finish"));
|
||||
&ld($a0,&QWPw(0,$ap));
|
||||
&ld($b0,&QWPw(0,$bp));
|
||||
&br(&label("loop"));
|
||||
##################################################
|
||||
# Do the last 0..3 words
|
||||
|
||||
&set_label("last_loop");
|
||||
|
||||
&ld($a0,&QWPw(0,$ap)); # get a
|
||||
&ld($b0,&QWPw(0,$bp)); # get b
|
||||
&cmpult($a0,$b0,$tmp); # will we borrow?
|
||||
&sub($a0,$b0,$a0); # do the subtract
|
||||
&cmpult($a0,$cc,$b0); # will we borrow?
|
||||
&sub($a0,$cc,$a0); # will we borrow?
|
||||
&st($a0,&QWPw(0,$rp)); # save
|
||||
&add($b0,$tmp,$cc); # add the borrows
|
||||
|
||||
&add($ap,$QWS,$ap);
|
||||
&add($bp,$QWS,$bp);
|
||||
&add($rp,$QWS,$rp);
|
||||
&sub($count,1,$count);
|
||||
&bgt($count,&label("last_loop"));
|
||||
&function_end_A($name);
|
||||
|
||||
######################################################
|
||||
&set_label("finish");
|
||||
&add($count,4,$count);
|
||||
&bgt($count,&label("last_loop"));
|
||||
|
||||
&FR($a0,$b0);
|
||||
&set_label("end");
|
||||
&function_end($name);
|
||||
|
||||
&fin_pool;
|
||||
}
|
||||
|
||||
1;
|
118
crypto/bn/asm/alpha/add.pl
Normal file
118
crypto/bn/asm/alpha/add.pl
Normal file
@@ -0,0 +1,118 @@
|
||||
#!/usr/local/bin/perl
|
||||
# alpha assember
|
||||
|
||||
sub bn_add_words
|
||||
{
|
||||
local($name)=@_;
|
||||
local($cc,$a,$b,$r);
|
||||
|
||||
&init_pool(4);
|
||||
($cc)=GR("r0");
|
||||
|
||||
$rp=&wparam(0);
|
||||
$ap=&wparam(1);
|
||||
$bp=&wparam(2);
|
||||
$count=&wparam(3);
|
||||
|
||||
&function_begin($name,"");
|
||||
|
||||
&comment("");
|
||||
&sub($count,4,$count);
|
||||
&mov("zero",$cc);
|
||||
&blt($count,&label("finish"));
|
||||
|
||||
($a0,$b0)=&NR(2);
|
||||
|
||||
##########################################################
|
||||
&set_label("loop");
|
||||
|
||||
&ld(($a0)=&NR(1),&QWPw(0,$ap));
|
||||
&ld(($b0)=&NR(1),&QWPw(0,$bp));
|
||||
&ld(($a1)=&NR(1),&QWPw(1,$ap));
|
||||
&ld(($b1)=&NR(1),&QWPw(1,$bp));
|
||||
|
||||
($o0,$t0)=&NR(2);
|
||||
&add($a0,$b0,$o0);
|
||||
&ld(($a2)=&NR(1),&QWPw(2,$ap));
|
||||
&cmpult($o0,$b0,$t0);
|
||||
&add($o0,$cc,$o0);
|
||||
&cmpult($o0,$cc,$cc);
|
||||
&ld(($b2)=&NR(1),&QWPw(2,$bp));
|
||||
&add($cc,$t0,$cc); &FR($t0);
|
||||
|
||||
($t1,$o1)=&NR(2);
|
||||
|
||||
&add($a1,$b1,$o1); &FR($a1);
|
||||
&cmpult($o1,$b1,$t1); &FR($b1);
|
||||
&add($o1,$cc,$o1);
|
||||
&cmpult($o1,$cc,$cc);
|
||||
&ld(($a3)=&NR(1),&QWPw(3,$ap));
|
||||
&add($cc,$t1,$cc); &FR($t1);
|
||||
|
||||
($t2,$o2)=&NR(2);
|
||||
|
||||
&add($a2,$b2,$o2); &FR($a2);
|
||||
&cmpult($o2,$b2,$t2); &FR($b2);
|
||||
&add($o2,$cc,$o2);
|
||||
&cmpult($o2,$cc,$cc);
|
||||
&ld(($b3)=&NR(1),&QWPw(3,$bp));
|
||||
&st($o0,&QWPw(0,$rp)); &FR($o0);
|
||||
&add($cc,$t2,$cc); &FR($t2);
|
||||
|
||||
($t3,$o3)=&NR(2);
|
||||
|
||||
&st($o1,&QWPw(0,$rp)); &FR($o1);
|
||||
&add($a3,$b3,$o3); &FR($a3);
|
||||
&cmpult($o3,$b3,$t3); &FR($b3);
|
||||
&add($o3,$cc,$o3);
|
||||
&st($o2,&QWPw(0,$rp)); &FR($o2);
|
||||
&cmpult($o3,$cc,$cc);
|
||||
&st($o3,&QWPw(0,$rp)); &FR($o3);
|
||||
&add($cc,$t3,$cc); &FR($t3);
|
||||
|
||||
|
||||
&sub($count,4,$count); # count-=4
|
||||
&add($ap,4*$QWS,$ap); # count+=4
|
||||
&add($bp,4*$QWS,$bp); # count+=4
|
||||
&add($rp,4*$QWS,$rp); # count+=4
|
||||
|
||||
###
|
||||
&bge($count,&label("loop"));
|
||||
###
|
||||
&br(&label("finish"));
|
||||
##################################################
|
||||
# Do the last 0..3 words
|
||||
|
||||
($t0,$o0)=&NR(2);
|
||||
&set_label("last_loop");
|
||||
|
||||
&ld($a0,&QWPw(0,$ap)); # get a
|
||||
&ld($b0,&QWPw(0,$bp)); # get b
|
||||
&add($ap,$QWS,$ap);
|
||||
&add($bp,$QWS,$bp);
|
||||
&add($a0,$b0,$o0);
|
||||
&sub($count,1,$count);
|
||||
&cmpult($o0,$b0,$t0); # will we borrow?
|
||||
&add($o0,$cc,$o0); # will we borrow?
|
||||
&cmpult($o0,$cc,$cc); # will we borrow?
|
||||
&add($rp,$QWS,$rp);
|
||||
&st($o0,&QWPw(-1,$rp)); # save
|
||||
&add($cc,$t0,$cc); # add the borrows
|
||||
|
||||
###
|
||||
&bgt($count,&label("last_loop"));
|
||||
&function_end_A($name);
|
||||
|
||||
######################################################
|
||||
&set_label("finish");
|
||||
&add($count,4,$count);
|
||||
&bgt($count,&label("last_loop"));
|
||||
|
||||
&FR($o0,$t0,$a0,$b0);
|
||||
&set_label("end");
|
||||
&function_end($name);
|
||||
|
||||
&fin_pool;
|
||||
}
|
||||
|
||||
1;
|
144
crypto/bn/asm/alpha/div.pl
Normal file
144
crypto/bn/asm/alpha/div.pl
Normal file
@@ -0,0 +1,144 @@
|
||||
#!/usr/local/bin/perl
|
||||
|
||||
sub bn_div_words
|
||||
{
|
||||
local($data)=<<'EOF';
|
||||
#
|
||||
# What follows was taken directly from the C compiler with a few
|
||||
# hacks to redo the lables.
|
||||
#
|
||||
.text
|
||||
.set noreorder
|
||||
.set volatile
|
||||
.align 3
|
||||
.globl bn_div_words
|
||||
.ent bn_div_words
|
||||
bn_div_words
|
||||
ldgp $29,0($27)
|
||||
bn_div_words.ng:
|
||||
lda $30,-48($30)
|
||||
.frame $30,48,$26,0
|
||||
stq $26,0($30)
|
||||
stq $9,8($30)
|
||||
stq $10,16($30)
|
||||
stq $11,24($30)
|
||||
stq $12,32($30)
|
||||
stq $13,40($30)
|
||||
.mask 0x4003e00,-48
|
||||
.prologue 1
|
||||
bis $16,$16,$9
|
||||
bis $17,$17,$10
|
||||
bis $18,$18,$11
|
||||
bis $31,$31,$13
|
||||
bis $31,2,$12
|
||||
bne $11,$9119
|
||||
lda $0,-1
|
||||
br $31,$9136
|
||||
.align 4
|
||||
$9119:
|
||||
bis $11,$11,$16
|
||||
jsr $26,BN_num_bits_word
|
||||
ldgp $29,0($26)
|
||||
subq $0,64,$1
|
||||
beq $1,$9120
|
||||
bis $31,1,$1
|
||||
sll $1,$0,$1
|
||||
cmpule $9,$1,$1
|
||||
bne $1,$9120
|
||||
# lda $16,_IO_stderr_
|
||||
# lda $17,$C32
|
||||
# bis $0,$0,$18
|
||||
# jsr $26,fprintf
|
||||
# ldgp $29,0($26)
|
||||
jsr $26,abort
|
||||
ldgp $29,0($26)
|
||||
.align 4
|
||||
$9120:
|
||||
bis $31,64,$3
|
||||
cmpult $9,$11,$2
|
||||
subq $3,$0,$1
|
||||
addl $1,$31,$0
|
||||
subq $9,$11,$1
|
||||
cmoveq $2,$1,$9
|
||||
beq $0,$9122
|
||||
zapnot $0,15,$2
|
||||
subq $3,$0,$1
|
||||
sll $11,$2,$11
|
||||
sll $9,$2,$3
|
||||
srl $10,$1,$1
|
||||
sll $10,$2,$10
|
||||
bis $3,$1,$9
|
||||
$9122:
|
||||
srl $11,32,$5
|
||||
zapnot $11,15,$6
|
||||
lda $7,-1
|
||||
.align 5
|
||||
$9123:
|
||||
srl $9,32,$1
|
||||
subq $1,$5,$1
|
||||
bne $1,$9126
|
||||
zapnot $7,15,$27
|
||||
br $31,$9127
|
||||
.align 4
|
||||
$9126:
|
||||
bis $9,$9,$24
|
||||
bis $5,$5,$25
|
||||
divqu $24,$25,$27
|
||||
$9127:
|
||||
srl $10,32,$4
|
||||
.align 5
|
||||
$9128:
|
||||
mulq $27,$5,$1
|
||||
subq $9,$1,$3
|
||||
zapnot $3,240,$1
|
||||
bne $1,$9129
|
||||
mulq $6,$27,$2
|
||||
sll $3,32,$1
|
||||
addq $1,$4,$1
|
||||
cmpule $2,$1,$2
|
||||
bne $2,$9129
|
||||
subq $27,1,$27
|
||||
br $31,$9128
|
||||
.align 4
|
||||
$9129:
|
||||
mulq $27,$6,$1
|
||||
mulq $27,$5,$4
|
||||
srl $1,32,$3
|
||||
sll $1,32,$1
|
||||
addq $4,$3,$4
|
||||
cmpult $10,$1,$2
|
||||
subq $10,$1,$10
|
||||
addq $2,$4,$2
|
||||
cmpult $9,$2,$1
|
||||
bis $2,$2,$4
|
||||
beq $1,$9134
|
||||
addq $9,$11,$9
|
||||
subq $27,1,$27
|
||||
$9134:
|
||||
subl $12,1,$12
|
||||
subq $9,$4,$9
|
||||
beq $12,$9124
|
||||
sll $27,32,$13
|
||||
sll $9,32,$2
|
||||
srl $10,32,$1
|
||||
sll $10,32,$10
|
||||
bis $2,$1,$9
|
||||
br $31,$9123
|
||||
.align 4
|
||||
$9124:
|
||||
bis $13,$27,$0
|
||||
$9136:
|
||||
ldq $26,0($30)
|
||||
ldq $9,8($30)
|
||||
ldq $10,16($30)
|
||||
ldq $11,24($30)
|
||||
ldq $12,32($30)
|
||||
ldq $13,40($30)
|
||||
addq $30,48,$30
|
||||
ret $31,($26),1
|
||||
.end bn_div_words
|
||||
EOF
|
||||
&asm_add($data);
|
||||
}
|
||||
|
||||
1;
|
104
crypto/bn/asm/alpha/mul.pl
Normal file
104
crypto/bn/asm/alpha/mul.pl
Normal file
@@ -0,0 +1,104 @@
|
||||
#!/usr/local/bin/perl
|
||||
# alpha assember
|
||||
|
||||
sub bn_mul_words
|
||||
{
|
||||
local($name)=@_;
|
||||
local($cc,$a,$b,$r,$couny);
|
||||
|
||||
&init_pool(4);
|
||||
($cc)=GR("r0");
|
||||
|
||||
$rp=&wparam(0);
|
||||
$ap=&wparam(1);
|
||||
$count=&wparam(2);
|
||||
$word=&wparam(3);
|
||||
|
||||
&function_begin($name,"");
|
||||
|
||||
&comment("");
|
||||
&sub($count,4,$count);
|
||||
&mov("zero",$cc);
|
||||
###
|
||||
&blt($count,&label("finish"));
|
||||
|
||||
($a0)=&NR(1); &ld($a0,&QWPw(0,$ap));
|
||||
|
||||
&set_label("loop");
|
||||
|
||||
($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
|
||||
($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
|
||||
|
||||
&muh($a0,$word,($h0)=&NR(1)); &FR($a0);
|
||||
($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
|
||||
### wait 8
|
||||
&mul($a0,$word,($l0)=&NR(1)); &FR($a0);
|
||||
### wait 8
|
||||
&muh($a1,$word,($h1)=&NR(1)); &FR($a1);
|
||||
&add($l0,$cc,$l0); ### wait 8
|
||||
&mul($a1,$word,($l1)=&NR(1)); &FR($a1);
|
||||
&cmpult($l0,$cc,$cc); ### wait 8
|
||||
&muh($a2,$word,($h2)=&NR(1)); &FR($a2);
|
||||
&add($h0,$cc,$cc); &FR($h0); ### wait 8
|
||||
&mul($a2,$word,($l2)=&NR(1)); &FR($a2);
|
||||
&add($l1,$cc,$l1); ### wait 8
|
||||
&st($l0,&QWPw(0,$rp)); &FR($l0);
|
||||
&cmpult($l1,$cc,$cc); ### wait 8
|
||||
&muh($a3,$word,($h3)=&NR(1)); &FR($a3);
|
||||
&add($h1,$cc,$cc); &FR($h1);
|
||||
&mul($a3,$word,($l3)=&NR(1)); &FR($a3);
|
||||
&add($l2,$cc,$l2);
|
||||
&st($l1,&QWPw(1,$rp)); &FR($l1);
|
||||
&cmpult($l2,$cc,$cc);
|
||||
&add($h2,$cc,$cc); &FR($h2);
|
||||
&sub($count,4,$count); # count-=4
|
||||
&st($l2,&QWPw(2,$rp)); &FR($l2);
|
||||
&add($l3,$cc,$l3);
|
||||
&cmpult($l3,$cc,$cc);
|
||||
&add($bp,4*$QWS,$bp); # count+=4
|
||||
&add($h3,$cc,$cc); &FR($h3);
|
||||
&add($ap,4*$QWS,$ap); # count+=4
|
||||
&st($l3,&QWPw(3,$rp)); &FR($l3);
|
||||
&add($rp,4*$QWS,$rp); # count+=4
|
||||
###
|
||||
&blt($count,&label("finish"));
|
||||
($a0)=&NR(1); &ld($a0,&QWPw(0,$ap));
|
||||
&br(&label("finish"));
|
||||
##################################################
|
||||
|
||||
##################################################
|
||||
# Do the last 0..3 words
|
||||
|
||||
&set_label("last_loop");
|
||||
|
||||
&ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
|
||||
###
|
||||
###
|
||||
###
|
||||
&muh($a0,$word,($h0)=&NR(1));
|
||||
### Wait 8 for next mul issue
|
||||
&mul($a0,$word,($l0)=&NR(1)); &FR($a0)
|
||||
&add($ap,$QWS,$ap);
|
||||
### Loose 12 until result is available
|
||||
&add($rp,$QWS,$rp);
|
||||
&sub($count,1,$count);
|
||||
&add($l0,$cc,$l0);
|
||||
###
|
||||
&st($l0,&QWPw(-1,$rp)); &FR($l0);
|
||||
&cmpult($l0,$cc,$cc);
|
||||
&add($h0,$cc,$cc); &FR($h0);
|
||||
&bgt($count,&label("last_loop"));
|
||||
&function_end_A($name);
|
||||
|
||||
######################################################
|
||||
&set_label("finish");
|
||||
&add($count,4,$count);
|
||||
&bgt($count,&label("last_loop"));
|
||||
|
||||
&set_label("end");
|
||||
&function_end($name);
|
||||
|
||||
&fin_pool;
|
||||
}
|
||||
|
||||
1;
|
123
crypto/bn/asm/alpha/mul_add.pl
Normal file
123
crypto/bn/asm/alpha/mul_add.pl
Normal file
@@ -0,0 +1,123 @@
|
||||
#!/usr/local/bin/perl
|
||||
# alpha assember
|
||||
|
||||
sub bn_mul_add_words
|
||||
{
|
||||
local($name)=@_;
|
||||
local($cc,$a,$b,$r,$couny);
|
||||
|
||||
&init_pool(4);
|
||||
($cc)=GR("r0");
|
||||
|
||||
$rp=&wparam(0);
|
||||
$ap=&wparam(1);
|
||||
$count=&wparam(2);
|
||||
$word=&wparam(3);
|
||||
|
||||
&function_begin($name,"");
|
||||
|
||||
&comment("");
|
||||
&sub($count,4,$count);
|
||||
&mov("zero",$cc);
|
||||
###
|
||||
&blt($count,&label("finish"));
|
||||
|
||||
&ld(($a0)=&NR(1),&QWPw(0,$ap));
|
||||
|
||||
$a=<<'EOF';
|
||||
##########################################################
|
||||
&set_label("loop");
|
||||
|
||||
&ld(($r0)=&NR(1),&QWPw(0,$rp));
|
||||
&ld(($a1)=&NR(1),&QWPw(1,$ap));
|
||||
&muh($a0,$word,($h0)=&NR(1));
|
||||
&ld(($r1)=&NR(1),&QWPw(1,$rp));
|
||||
&ld(($a2)=&NR(1),&QWPw(2,$ap));
|
||||
###
|
||||
&mul($a0,$word,($l0)=&NR(1)); &FR($a0);
|
||||
&ld(($r2)=&NR(1),&QWPw(2,$rp));
|
||||
&muh($a1,$word,($h1)=&NR(1));
|
||||
&ld(($a3)=&NR(1),&QWPw(3,$ap));
|
||||
&mul($a1,$word,($l1)=&NR(1)); &FR($a1);
|
||||
&ld(($r3)=&NR(1),&QWPw(3,$rp));
|
||||
&add($r0,$l0,$r0);
|
||||
&add($r1,$l1,$r1);
|
||||
&cmpult($r0,$l0,($t0)=&NR(1)); &FR($l0);
|
||||
&cmpult($r1,$l1,($t1)=&NR(1)); &FR($l1);
|
||||
&muh($a2,$word,($h2)=&NR(1));
|
||||
&add($r0,$cc,$r0);
|
||||
&add($h0,$t0,$h0); &FR($t0);
|
||||
&cmpult($r0,$cc,$cc);
|
||||
&add($h1,$t1,$h1); &FR($t1);
|
||||
&add($h0,$cc,$cc); &FR($h0);
|
||||
&mul($a2,$word,($l2)=&NR(1)); &FR($a2);
|
||||
&add($r1,$cc,$r1);
|
||||
&cmpult($r1,$cc,$cc);
|
||||
&add($r2,$l2,$r2);
|
||||
&add($h1,$cc,$cc); &FR($h1);
|
||||
&cmpult($r2,$l2,($t2)=&NR(1)); &FR($l2);
|
||||
&muh($a3,$word,($h3)=&NR(1));
|
||||
&add($r2,$cc,$r2);
|
||||
&st($r0,&QWPw(0,$rp)); &FR($r0);
|
||||
&add($h2,$t2,$h2); &FR($t2);
|
||||
&st($r1,&QWPw(1,$rp)); &FR($r1);
|
||||
&cmpult($r2,$cc,$cc);
|
||||
&mul($a3,$word,($l3)=&NR(1)); &FR($a3);
|
||||
&add($h2,$cc,$cc); &FR($h2);
|
||||
&st($r2,&QWPw(2,$rp)); &FR($r2);
|
||||
&sub($count,4,$count); # count-=4
|
||||
&add($rp,4*$QWS,$rp); # count+=4
|
||||
&add($r3,$l3,$r3);
|
||||
&add($ap,4*$QWS,$ap); # count+=4
|
||||
&cmpult($r3,$l3,($t3)=&NR(1)); &FR($l3);
|
||||
&add($r3,$cc,$r3);
|
||||
&add($h3,$t3,$h3); &FR($t3);
|
||||
&cmpult($r3,$cc,$cc);
|
||||
&st($r3,&QWPw(-1,$rp)); &FR($r3);
|
||||
&add($h3,$cc,$cc); &FR($h3);
|
||||
|
||||
###
|
||||
&blt($count,&label("finish"));
|
||||
&ld(($a0)=&NR(1),&QWPw(0,$ap));
|
||||
&br(&label("loop"));
|
||||
EOF
|
||||
##################################################
|
||||
# Do the last 0..3 words
|
||||
|
||||
&set_label("last_loop");
|
||||
|
||||
&ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
|
||||
&ld(($r0)=&NR(1),&QWPw(0,$rp)); # get b
|
||||
###
|
||||
###
|
||||
&muh($a0,$word,($h0)=&NR(1)); &FR($a0);
|
||||
### wait 8
|
||||
&mul($a0,$word,($l0)=&NR(1)); &FR($a0);
|
||||
&add($rp,$QWS,$rp);
|
||||
&add($ap,$QWS,$ap);
|
||||
&sub($count,1,$count);
|
||||
### wait 3 until l0 is available
|
||||
&add($r0,$l0,$r0);
|
||||
###
|
||||
&cmpult($r0,$l0,($t0)=&NR(1)); &FR($l0);
|
||||
&add($r0,$cc,$r0);
|
||||
&add($h0,$t0,$h0); &FR($t0);
|
||||
&cmpult($r0,$cc,$cc);
|
||||
&add($h0,$cc,$cc); &FR($h0);
|
||||
|
||||
&st($r0,&QWPw(-1,$rp)); &FR($r0);
|
||||
&bgt($count,&label("last_loop"));
|
||||
&function_end_A($name);
|
||||
|
||||
######################################################
|
||||
&set_label("finish");
|
||||
&add($count,4,$count);
|
||||
&bgt($count,&label("last_loop"));
|
||||
|
||||
&set_label("end");
|
||||
&function_end($name);
|
||||
|
||||
&fin_pool;
|
||||
}
|
||||
|
||||
1;
|
215
crypto/bn/asm/alpha/mul_c4.pl
Normal file
215
crypto/bn/asm/alpha/mul_c4.pl
Normal file
@@ -0,0 +1,215 @@
|
||||
#!/usr/local/bin/perl
|
||||
# alpha assember
|
||||
|
||||
# upto
|
||||
|
||||
sub mul_add_c
|
||||
{
|
||||
local($a,$b,$c0,$c1,$c2)=@_;
|
||||
local($l1,$h1,$t1,$t2);
|
||||
|
||||
&mul($a,$b,($l1)=&NR(1));
|
||||
&muh($a,$b,($h1)=&NR(1));
|
||||
&add($c0,$l1,$c0);
|
||||
&cmpult($c0,$l1,($t1)=&NR(1)); &FR($l1);
|
||||
&add($t1,$h1,$h1); &FR($t1);
|
||||
&add($c1,$h1,$c1);
|
||||
&cmpult($c1,$h1,($t2)=&NR(1)); &FR($h1);
|
||||
&add($c2,$t2,$c2); &FR($t2);
|
||||
}
|
||||
|
||||
sub bn_mul_comba4
|
||||
{
|
||||
local($name)=@_;
|
||||
local(@a,@b,$r,$c0,$c1,$c2);
|
||||
|
||||
$cnt=1;
|
||||
&init_pool(3);
|
||||
|
||||
$rp=&wparam(0);
|
||||
$ap=&wparam(1);
|
||||
$bp=&wparam(2);
|
||||
|
||||
&function_begin($name,"");
|
||||
|
||||
&comment("");
|
||||
|
||||
&ld(($a[0])=&NR(1),&QWPw(0,$ap));
|
||||
&ld(($b[0])=&NR(1),&QWPw(0,$bp));
|
||||
&ld(($a[1])=&NR(1),&QWPw(1,$ap));
|
||||
&ld(($b[1])=&NR(1),&QWPw(1,$bp));
|
||||
&mul($a[0],$b[0],($r00)=&NR(1));
|
||||
&ld(($a[2])=&NR(1),&QWPw(2,$ap));
|
||||
&ld(($b[2])=&NR(1),&QWPw(2,$bp));
|
||||
&muh($a[0],$b[0],($r01)=&NR(1));
|
||||
&FR($ap); &ld(($a[3])=&NR(1),&QWPw(3,$ap));
|
||||
&FR($bp); &ld(($b[3])=&NR(1),&QWPw(3,$bp));
|
||||
&mul($a[0],$b[1],($r02)=&NR(1));
|
||||
|
||||
($R,$H1,$H2)=&NR(3);
|
||||
|
||||
&st($r00,&QWPw(0,$rp)); &FR($r00);
|
||||
|
||||
&mov("zero",$R);
|
||||
&mul($a[1],$b[0],($r03)=&NR(1));
|
||||
|
||||
&mov("zero",$H1);
|
||||
&mov("zero",$H0);
|
||||
&add($R,$r01,$R);
|
||||
&muh($a[0],$b[1],($r04)=&NR(1));
|
||||
&cmpult($R,$r01,($t01)=&NR(1)); &FR($r01);
|
||||
&add($R,$r02,$R);
|
||||
&add($H1,$t01,$H1) &FR($t01);
|
||||
&muh($a[1],$b[0],($r05)=&NR(1));
|
||||
&cmpult($R,$r02,($t02)=&NR(1)); &FR($r02);
|
||||
&add($R,$r03,$R);
|
||||
&add($H2,$t02,$H2) &FR($t02);
|
||||
&mul($a[0],$b[2],($r06)=&NR(1));
|
||||
&cmpult($R,$r03,($t03)=&NR(1)); &FR($r03);
|
||||
&add($H1,$t03,$H1) &FR($t03);
|
||||
&st($R,&QWPw(1,$rp));
|
||||
&add($H1,$H2,$R);
|
||||
|
||||
&mov("zero",$H1);
|
||||
&add($R,$r04,$R);
|
||||
&mov("zero",$H2);
|
||||
&mul($a[1],$b[1],($r07)=&NR(1));
|
||||
&cmpult($R,$r04,($t04)=&NR(1)); &FR($r04);
|
||||
&add($R,$r05,$R);
|
||||
&add($H1,$t04,$H1) &FR($t04);
|
||||
&mul($a[2],$b[0],($r08)=&NR(1));
|
||||
&cmpult($R,$r05,($t05)=&NR(1)); &FR($r05);
|
||||
&add($R,$r01,$R);
|
||||
&add($H2,$t05,$H2) &FR($t05);
|
||||
&muh($a[0],$b[2],($r09)=&NR(1));
|
||||
&cmpult($R,$r06,($t06)=&NR(1)); &FR($r06);
|
||||
&add($R,$r07,$R);
|
||||
&add($H1,$t06,$H1) &FR($t06);
|
||||
&muh($a[1],$b[1],($r10)=&NR(1));
|
||||
&cmpult($R,$r07,($t07)=&NR(1)); &FR($r07);
|
||||
&add($R,$r08,$R);
|
||||
&add($H2,$t07,$H2) &FR($t07);
|
||||
&muh($a[2],$b[0],($r11)=&NR(1));
|
||||
&cmpult($R,$r08,($t08)=&NR(1)); &FR($r08);
|
||||
&add($H1,$t08,$H1) &FR($t08);
|
||||
&st($R,&QWPw(2,$rp));
|
||||
&add($H1,$H2,$R);
|
||||
|
||||
&mov("zero",$H1);
|
||||
&add($R,$r09,$R);
|
||||
&mov("zero",$H2);
|
||||
&mul($a[0],$b[3],($r12)=&NR(1));
|
||||
&cmpult($R,$r09,($t09)=&NR(1)); &FR($r09);
|
||||
&add($R,$r10,$R);
|
||||
&add($H1,$t09,$H1) &FR($t09);
|
||||
&mul($a[1],$b[2],($r13)=&NR(1));
|
||||
&cmpult($R,$r10,($t10)=&NR(1)); &FR($r10);
|
||||
&add($R,$r11,$R);
|
||||
&add($H1,$t10,$H1) &FR($t10);
|
||||
&mul($a[2],$b[1],($r14)=&NR(1));
|
||||
&cmpult($R,$r11,($t11)=&NR(1)); &FR($r11);
|
||||
&add($R,$r12,$R);
|
||||
&add($H1,$t11,$H1) &FR($t11);
|
||||
&mul($a[3],$b[0],($r15)=&NR(1));
|
||||
&cmpult($R,$r12,($t12)=&NR(1)); &FR($r12);
|
||||
&add($R,$r13,$R);
|
||||
&add($H1,$t12,$H1) &FR($t12);
|
||||
&muh($a[0],$b[3],($r16)=&NR(1));
|
||||
&cmpult($R,$r13,($t13)=&NR(1)); &FR($r13);
|
||||
&add($R,$r14,$R);
|
||||
&add($H1,$t13,$H1) &FR($t13);
|
||||
&muh($a[1],$b[2],($r17)=&NR(1));
|
||||
&cmpult($R,$r14,($t14)=&NR(1)); &FR($r14);
|
||||
&add($R,$r15,$R);
|
||||
&add($H1,$t14,$H1) &FR($t14);
|
||||
&muh($a[2],$b[1],($r18)=&NR(1));
|
||||
&cmpult($R,$r15,($t15)=&NR(1)); &FR($r15);
|
||||
&add($H1,$t15,$H1) &FR($t15);
|
||||
&st($R,&QWPw(3,$rp));
|
||||
&add($H1,$H2,$R);
|
||||
|
||||
&mov("zero",$H1);
|
||||
&add($R,$r16,$R);
|
||||
&mov("zero",$H2);
|
||||
&muh($a[3],$b[0],($r19)=&NR(1));
|
||||
&cmpult($R,$r16,($t16)=&NR(1)); &FR($r16);
|
||||
&add($R,$r17,$R);
|
||||
&add($H1,$t16,$H1) &FR($t16);
|
||||
&mul($a[1],$b[3],($r20)=&NR(1));
|
||||
&cmpult($R,$r17,($t17)=&NR(1)); &FR($r17);
|
||||
&add($R,$r18,$R);
|
||||
&add($H1,$t17,$H1) &FR($t17);
|
||||
&mul($a[2],$b[2],($r21)=&NR(1));
|
||||
&cmpult($R,$r18,($t18)=&NR(1)); &FR($r18);
|
||||
&add($R,$r19,$R);
|
||||
&add($H1,$t18,$H1) &FR($t18);
|
||||
&mul($a[3],$b[1],($r22)=&NR(1));
|
||||
&cmpult($R,$r19,($t19)=&NR(1)); &FR($r19);
|
||||
&add($R,$r20,$R);
|
||||
&add($H1,$t19,$H1) &FR($t19);
|
||||
&muh($a[1],$b[3],($r23)=&NR(1));
|
||||
&cmpult($R,$r20,($t20)=&NR(1)); &FR($r20);
|
||||
&add($R,$r21,$R);
|
||||
&add($H1,$t20,$H1) &FR($t20);
|
||||
&muh($a[2],$b[2],($r24)=&NR(1));
|
||||
&cmpult($R,$r21,($t21)=&NR(1)); &FR($r21);
|
||||
&add($R,$r22,$R);
|
||||
&add($H1,$t21,$H1) &FR($t21);
|
||||
&muh($a[3],$b[1],($r25)=&NR(1));
|
||||
&cmpult($R,$r22,($t22)=&NR(1)); &FR($r22);
|
||||
&add($H1,$t22,$H1) &FR($t22);
|
||||
&st($R,&QWPw(4,$rp));
|
||||
&add($H1,$H2,$R);
|
||||
|
||||
&mov("zero",$H1);
|
||||
&add($R,$r23,$R);
|
||||
&mov("zero",$H2);
|
||||
&mul($a[2],$b[3],($r26)=&NR(1));
|
||||
&cmpult($R,$r23,($t23)=&NR(1)); &FR($r23);
|
||||
&add($R,$r24,$R);
|
||||
&add($H1,$t23,$H1) &FR($t23);
|
||||
&mul($a[3],$b[2],($r27)=&NR(1));
|
||||
&cmpult($R,$r24,($t24)=&NR(1)); &FR($r24);
|
||||
&add($R,$r25,$R);
|
||||
&add($H1,$t24,$H1) &FR($t24);
|
||||
&muh($a[2],$b[3],($r28)=&NR(1));
|
||||
&cmpult($R,$r25,($t25)=&NR(1)); &FR($r25);
|
||||
&add($R,$r26,$R);
|
||||
&add($H1,$t25,$H1) &FR($t25);
|
||||
&muh($a[3],$b[2],($r29)=&NR(1));
|
||||
&cmpult($R,$r26,($t26)=&NR(1)); &FR($r26);
|
||||
&add($R,$r27,$R);
|
||||
&add($H1,$t26,$H1) &FR($t26);
|
||||
&mul($a[3],$b[3],($r30)=&NR(1));
|
||||
&cmpult($R,$r27,($t27)=&NR(1)); &FR($r27);
|
||||
&add($H1,$t27,$H1) &FR($t27);
|
||||
&st($R,&QWPw(5,$rp));
|
||||
&add($H1,$H2,$R);
|
||||
|
||||
&mov("zero",$H1);
|
||||
&add($R,$r28,$R);
|
||||
&mov("zero",$H2);
|
||||
&muh($a[3],$b[3],($r31)=&NR(1));
|
||||
&cmpult($R,$r28,($t28)=&NR(1)); &FR($r28);
|
||||
&add($R,$r29,$R);
|
||||
&add($H1,$t28,$H1) &FR($t28);
|
||||
############
|
||||
&cmpult($R,$r29,($t29)=&NR(1)); &FR($r29);
|
||||
&add($R,$r30,$R);
|
||||
&add($H1,$t29,$H1) &FR($t29);
|
||||
############
|
||||
&cmpult($R,$r30,($t30)=&NR(1)); &FR($r30);
|
||||
&add($H1,$t30,$H1) &FR($t30);
|
||||
&st($R,&QWPw(6,$rp));
|
||||
&add($H1,$H2,$R);
|
||||
|
||||
&add($R,$r31,$R); &FR($r31);
|
||||
&st($R,&QWPw(7,$rp));
|
||||
|
||||
&FR($R,$H1,$H2);
|
||||
&function_end($name);
|
||||
|
||||
&fin_pool;
|
||||
}
|
||||
|
||||
1;
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user