2 * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
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
11 #include "internal/cryptlib.h"
12 #include <openssl/evp.h>
13 #include <openssl/objects.h>
14 #include <openssl/x509.h>
16 int X509_certificate_type(const X509
*x
, const EVP_PKEY
*pkey
)
25 pk
= X509_get0_pubkey(x
);
32 switch (EVP_PKEY_id(pk
)) {
34 ret
= EVP_PK_RSA
| EVP_PKT_SIGN
;
35 /* if (!sign only extension) */
38 case EVP_PKEY_RSA_PSS
:
39 ret
= EVP_PK_RSA
| EVP_PKT_SIGN
;
42 ret
= EVP_PK_DSA
| EVP_PKT_SIGN
;
45 ret
= EVP_PK_EC
| EVP_PKT_SIGN
| EVP_PKT_EXCH
;
48 case EVP_PKEY_ED25519
:
52 ret
= EVP_PK_DH
| EVP_PKT_EXCH
;
54 case NID_id_GostR3410_2001
:
55 case NID_id_GostR3410_2012_256
:
56 case NID_id_GostR3410_2012_512
:
57 ret
= EVP_PKT_EXCH
| EVP_PKT_SIGN
;
63 i
= X509_get_signature_nid(x
);
64 if (i
&& OBJ_find_sigid_algs(i
, NULL
, &i
)) {
67 case NID_rsaEncryption
:
75 case NID_X9_62_id_ecPublicKey
: