~ubuntu-branches/ubuntu/utopic/openssl/utopic

« back to all changes in this revision

Viewing changes to crypto/asn1/i2d_pr.c

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2011-04-02 13:19:19 UTC
  • mfrom: (1.2.1 upstream) (11.2.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 55.
  • Revision ID: james.westby@ubuntu.com-20110402131919-anszuslper64ey9e
Tags: 1.0.0d-1
* New upstream version
  - Fixes CVE-2011-0014
* Make libssl-doc Replaces/Breaks with old libssl-dev packages
  (Closes: #607609)
* Only export the symbols we should, instead of all.
* Add symbol file.
* Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
 
59
59
#include <stdio.h>
60
60
#include "cryptlib.h"
61
 
#include <openssl/bn.h>
62
61
#include <openssl/evp.h>
63
 
#include <openssl/objects.h>
64
 
#ifndef OPENSSL_NO_RSA
65
 
#include <openssl/rsa.h>
66
 
#endif
67
 
#ifndef OPENSSL_NO_DSA
68
 
#include <openssl/dsa.h>
69
 
#endif
70
 
#ifndef OPENSSL_NO_EC
71
 
#include <openssl/ec.h>
72
 
#endif
 
62
#include <openssl/x509.h>
 
63
#include "asn1_locl.h"
73
64
 
74
65
int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp)
75
66
        {
76
 
#ifndef OPENSSL_NO_RSA
77
 
        if (a->type == EVP_PKEY_RSA)
78
 
                {
79
 
                return(i2d_RSAPrivateKey(a->pkey.rsa,pp));
80
 
                }
81
 
        else
82
 
#endif
83
 
#ifndef OPENSSL_NO_DSA
84
 
        if (a->type == EVP_PKEY_DSA)
85
 
                {
86
 
                return(i2d_DSAPrivateKey(a->pkey.dsa,pp));
87
 
                }
88
 
#endif
89
 
#ifndef OPENSSL_NO_EC
90
 
        if (a->type == EVP_PKEY_EC)
91
 
                {
92
 
                return(i2d_ECPrivateKey(a->pkey.ec, pp));
93
 
                }
94
 
#endif
95
 
 
 
67
        if (a->ameth && a->ameth->old_priv_encode)
 
68
                {
 
69
                return a->ameth->old_priv_encode(a, pp);
 
70
                }
 
71
        if (a->ameth && a->ameth->priv_encode) {
 
72
                PKCS8_PRIV_KEY_INFO *p8 = EVP_PKEY2PKCS8(a);
 
73
                int ret = i2d_PKCS8_PRIV_KEY_INFO(p8,pp);
 
74
                PKCS8_PRIV_KEY_INFO_free(p8);
 
75
                return ret;
 
76
        }       
96
77
        ASN1err(ASN1_F_I2D_PRIVATEKEY,ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE);
97
78
        return(-1);
98
79
        }