Coverage Report

Created: 2025-11-17 06:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/boringssl/crypto/x509/i2d_pr.cc
Line
Count
Source
1
// Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include <openssl/asn1.h>
16
#include <openssl/dsa.h>
17
#include <openssl/ec_key.h>
18
#include <openssl/err.h>
19
#include <openssl/evp.h>
20
#include <openssl/rsa.h>
21
22
23
0
int i2d_PrivateKey(const EVP_PKEY *a, uint8_t **pp) {
24
0
  switch (EVP_PKEY_id(a)) {
25
0
    case EVP_PKEY_RSA:
26
0
      return i2d_RSAPrivateKey(EVP_PKEY_get0_RSA(a), pp);
27
0
    case EVP_PKEY_EC:
28
0
      return i2d_ECPrivateKey(EVP_PKEY_get0_EC_KEY(a), pp);
29
0
    case EVP_PKEY_DSA:
30
0
      return i2d_DSAPrivateKey(EVP_PKEY_get0_DSA(a), pp);
31
0
    default:
32
      // Although this file is in crypto/x509 for layering reasons, it emits
33
      // an error code from ASN1 for OpenSSL compatibility.
34
0
      OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE);
35
0
      return -1;
36
0
  }
37
0
}