~ubuntu-branches/ubuntu/hardy/openssl/hardy-security

« back to all changes in this revision

Viewing changes to crypto/asn1/d2i_pr.c

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2005-12-13 21:37:42 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051213213742-7em5nrw5c7ceegyd
Tags: 0.9.8a-5
Stop ssh from crashing randomly on sparc (Closes: #335912)
Patch from upstream cvs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
#ifndef OPENSSL_NO_DSA
69
69
#include <openssl/dsa.h>
70
70
#endif
 
71
#ifndef OPENSSL_NO_EC
 
72
#include <openssl/ec.h>
 
73
#endif
71
74
 
72
 
EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, unsigned char **pp,
 
75
EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
73
76
             long length)
74
77
        {
75
78
        EVP_PKEY *ret;
108
111
                        }
109
112
                break;
110
113
#endif
 
114
#ifndef OPENSSL_NO_EC
 
115
        case EVP_PKEY_EC:
 
116
                if ((ret->pkey.ec = d2i_ECPrivateKey(NULL, 
 
117
                        (const unsigned char **)pp, length)) == NULL)
 
118
                        {
 
119
                        ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_ASN1_LIB);
 
120
                        goto err;
 
121
                        }
 
122
                break;
 
123
#endif
111
124
        default:
112
125
                ASN1err(ASN1_F_D2I_PRIVATEKEY,ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE);
113
126
                goto err;
122
135
 
123
136
/* This works like d2i_PrivateKey() except it automatically works out the type */
124
137
 
125
 
EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, unsigned char **pp,
 
138
EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,
126
139
             long length)
127
140
{
128
141
        STACK_OF(ASN1_TYPE) *inkey;
129
 
        unsigned char *p;
 
142
        const unsigned char *p;
130
143
        int keytype;
131
144
        p = *pp;
132
145
        /* Dirty trick: read in the ASN1 data into a STACK_OF(ASN1_TYPE):
138
151
        /* Since we only need to discern "traditional format" RSA and DSA
139
152
         * keys we can just count the elements.
140
153
         */
141
 
        if(sk_ASN1_TYPE_num(inkey) == 6) keytype = EVP_PKEY_DSA;
 
154
        if(sk_ASN1_TYPE_num(inkey) == 6) 
 
155
                keytype = EVP_PKEY_DSA;
 
156
        else if (sk_ASN1_TYPE_num(inkey) == 4)
 
157
                keytype = EVP_PKEY_EC;
142
158
        else keytype = EVP_PKEY_RSA;
143
159
        sk_ASN1_TYPE_pop_free(inkey, ASN1_TYPE_free);
144
160
        return d2i_PrivateKey(keytype, a, pp, length);