diff options
author | Dr. Stephen Henson <steve@openssl.org> | 1999-07-27 22:22:58 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 1999-07-27 22:22:58 +0000 |
commit | 3e3d2ea2fc9e9b702f94d5870f1a0a2f0c4c59f5 (patch) | |
tree | a65eed742f24248a7f07d5c8fe40c4675a2ebfda | |
parent | 770d19b862113f075a66a188a7be56f4b1f56251 (diff) |
New function OBJ_obj2txt()
-rw-r--r-- | CHANGES | 6 | ||||
-rw-r--r-- | crypto/asn1/a_object.c | 74 | ||||
-rw-r--r-- | crypto/objects/obj_dat.c | 66 | ||||
-rw-r--r-- | crypto/objects/objects.h | 1 | ||||
-rwxr-xr-x | util/libeay.num | 1 |
5 files changed, 77 insertions, 71 deletions
@@ -4,6 +4,12 @@ Changes between 0.9.3a and 0.9.4 [xx Jul/Aug/...? 1999] + *) New function OBJ_obj2txt(buf, buf_len, a, no_name), this converts + an ASN1_OBJECT to a text string. If the "no_name" parameter is set then + it will always use the numerical form of the OID, even if it has a short + or long name. + [Steve Henson] + *) Added an extra RSA flag: RSA_FLAG_EXT_PKEY. Previously the rsa_mod_exp method only got called if p,q,dmp1,dmq1,iqmp components were present, otherwise bn_mod_exp was called. In the case of hardware keys for example diff --git a/crypto/asn1/a_object.c b/crypto/asn1/a_object.c index 3a8ae0305d..b94b418ee8 100644 --- a/crypto/asn1/a_object.c +++ b/crypto/asn1/a_object.c @@ -171,77 +171,9 @@ err: } int i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a) - { - int i,idx=0,n=0,len,nid; - unsigned long l; - unsigned char *p; - const char *s; - char tbuf[32]; - - if (buf_len <= 0) return(0); - - if ((a == NULL) || (a->data == NULL)) - { - buf[0]='\0'; - return(0); - } - - nid=OBJ_obj2nid(a); - if (nid == NID_undef) - { - len=a->length; - p=a->data; - - idx=0; - l=0; - while (idx < a->length) - { - l|=(p[idx]&0x7f); - if (!(p[idx] & 0x80)) break; - l<<=7L; - idx++; - } - idx++; - i=(int)(l/40); - if (i > 2) i=2; - l-=(long)(i*40); - - sprintf(tbuf,"%d.%lu",i,l); - i=strlen(tbuf); - strncpy(buf,tbuf,buf_len); - buf_len-=i; - buf+=i; - n+=i; - - l=0; - for (; idx<len; idx++) - { - l|=p[idx]&0x7f; - if (!(p[idx] & 0x80)) - { - sprintf(tbuf,".%lu",l); - i=strlen(tbuf); - if (buf_len > 0) - strncpy(buf,tbuf,buf_len); - buf_len-=i; - buf+=i; - n+=i; - l=0; - } - l<<=7L; - } - } - else - { - s=OBJ_nid2ln(nid); - if (s == NULL) - s=OBJ_nid2sn(nid); - strncpy(buf,s,buf_len); - n=strlen(s); - } - buf[buf_len-1]='\0'; - return(n); - } +{ + return OBJ_obj2txt(buf, buf_len, a, 0); +} int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a) { diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c index d56edcdf96..d47b874399 100644 --- a/crypto/objects/obj_dat.c +++ b/crypto/objects/obj_dat.c @@ -418,6 +418,72 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name) return op; } +int OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *a, int no_name) +{ + int i,idx=0,n=0,len,nid; + unsigned long l; + unsigned char *p; + const char *s; + char tbuf[32]; + + if (buf_len <= 0) return(0); + + if ((a == NULL) || (a->data == NULL)) { + buf[0]='\0'; + return(0); + } + + nid=OBJ_obj2nid(a); + if ((nid == NID_undef) || no_name) { + len=a->length; + p=a->data; + + idx=0; + l=0; + while (idx < a->length) { + l|=(p[idx]&0x7f); + if (!(p[idx] & 0x80)) break; + l<<=7L; + idx++; + } + idx++; + i=(int)(l/40); + if (i > 2) i=2; + l-=(long)(i*40); + + sprintf(tbuf,"%d.%lu",i,l); + i=strlen(tbuf); + strncpy(buf,tbuf,buf_len); + buf_len-=i; + buf+=i; + n+=i; + + l=0; + for (; idx<len; idx++) { + l|=p[idx]&0x7f; + if (!(p[idx] & 0x80)) { + sprintf(tbuf,".%lu",l); + i=strlen(tbuf); + if (buf_len > 0) + strncpy(buf,tbuf,buf_len); + buf_len-=i; + buf+=i; + n+=i; + l=0; + } + l<<=7L; + } + } else { + s=OBJ_nid2ln(nid); + if (s == NULL) + s=OBJ_nid2sn(nid); + strncpy(buf,s,buf_len); + n=strlen(s); + } + buf[buf_len-1]='\0'; + return(n); +} + int OBJ_txt2nid(char *s) { ASN1_OBJECT *obj; diff --git a/crypto/objects/objects.h b/crypto/objects/objects.h index e0f88f1f03..d03748e022 100644 --- a/crypto/objects/objects.h +++ b/crypto/objects/objects.h @@ -928,6 +928,7 @@ const char * OBJ_nid2ln(int n); const char * OBJ_nid2sn(int n); int OBJ_obj2nid(ASN1_OBJECT *o); ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name); +int OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *a, int no_name); int OBJ_txt2nid(char *s); int OBJ_ln2nid(const char *s); int OBJ_sn2nid(const char *s); diff --git a/util/libeay.num b/util/libeay.num index 2761f90589..97787a5975 100755 --- a/util/libeay.num +++ b/util/libeay.num @@ -1842,3 +1842,4 @@ sk_POLICYQUALINFO_sort 1866 sk_X509_CRL_sort 1867 sk_DIST_POINT_sort 1868 RSA_check_key 1869 +OBJ_obj2txt 1870 |