]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/asn1/i2d_pu.c
Deprecate the low level DSA functions.
[thirdparty/openssl.git] / crypto / asn1 / i2d_pu.c
CommitLineData
2039c421
RS
1/*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
d02b48c6 3 *
365a2d99 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
2039c421
RS
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
d02b48c6
RE
8 */
9
f41ac0ee
P
10/*
11 * DSA low level APIs are deprecated for public use, but still ok for
12 * internal use.
13 */
14#include "internal/deprecated.h"
15
d02b48c6 16#include <stdio.h>
b39fc560 17#include "internal/cryptlib.h"
ec577822
BM
18#include <openssl/bn.h>
19#include <openssl/evp.h>
20#include <openssl/objects.h>
3c27208f
RS
21#include <openssl/rsa.h>
22#include <openssl/dsa.h>
23#include <openssl/ec.h>
d02b48c6 24
9fdcc21f 25int i2d_PublicKey(const EVP_PKEY *a, unsigned char **pp)
0f113f3e 26{
3aeb9348 27 switch (EVP_PKEY_id(a)) {
cf1b7d96 28#ifndef OPENSSL_NO_RSA
0f113f3e 29 case EVP_PKEY_RSA:
3aeb9348 30 return i2d_RSAPublicKey(EVP_PKEY_get0_RSA(a), pp);
d02b48c6 31#endif
cf1b7d96 32#ifndef OPENSSL_NO_DSA
0f113f3e 33 case EVP_PKEY_DSA:
3aeb9348 34 return i2d_DSAPublicKey(EVP_PKEY_get0_DSA(a), pp);
4d94ae00 35#endif
14a7cfb3 36#ifndef OPENSSL_NO_EC
0f113f3e 37 case EVP_PKEY_EC:
3aeb9348 38 return i2o_ECPublicKey(EVP_PKEY_get0_EC_KEY(a), pp);
d02b48c6 39#endif
0f113f3e
MC
40 default:
41 ASN1err(ASN1_F_I2D_PUBLICKEY, ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE);
3aeb9348 42 return -1;
0f113f3e
MC
43 }
44}