1e1051a39Sopenharmony_ci/* 2e1051a39Sopenharmony_ci * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci * 4e1051a39Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci * this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci * in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci * https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci */ 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ci#include <openssl/opensslconf.h> 11e1051a39Sopenharmony_ci#include "internal/cryptlib.h" 12e1051a39Sopenharmony_ci#include <stdio.h> 13e1051a39Sopenharmony_ci#include <openssl/rsa.h> 14e1051a39Sopenharmony_ci#include <openssl/objects.h> 15e1051a39Sopenharmony_ci#include <openssl/asn1t.h> 16e1051a39Sopenharmony_ci#include <openssl/evp.h> 17e1051a39Sopenharmony_ci#include <openssl/x509.h> 18e1051a39Sopenharmony_ci 19e1051a39Sopenharmony_ci#define ASN1_BROKEN_SEQUENCE(tname) \ 20e1051a39Sopenharmony_ci static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \ 21e1051a39Sopenharmony_ci ASN1_SEQUENCE(tname) 22e1051a39Sopenharmony_ci#define static_ASN1_BROKEN_SEQUENCE_END(stname) \ 23e1051a39Sopenharmony_ci static_ASN1_SEQUENCE_END_ref(stname, stname) 24e1051a39Sopenharmony_ci 25e1051a39Sopenharmony_citypedef struct netscape_pkey_st { 26e1051a39Sopenharmony_ci int32_t version; 27e1051a39Sopenharmony_ci X509_ALGOR *algor; 28e1051a39Sopenharmony_ci ASN1_OCTET_STRING *private_key; 29e1051a39Sopenharmony_ci} NETSCAPE_PKEY; 30e1051a39Sopenharmony_ci 31e1051a39Sopenharmony_citypedef struct netscape_encrypted_pkey_st { 32e1051a39Sopenharmony_ci ASN1_OCTET_STRING *os; 33e1051a39Sopenharmony_ci /* 34e1051a39Sopenharmony_ci * This is the same structure as DigestInfo so use it: although this 35e1051a39Sopenharmony_ci * isn't really anything to do with digests. 36e1051a39Sopenharmony_ci */ 37e1051a39Sopenharmony_ci X509_SIG *enckey; 38e1051a39Sopenharmony_ci} NETSCAPE_ENCRYPTED_PKEY; 39e1051a39Sopenharmony_ci 40e1051a39Sopenharmony_ci 41e1051a39Sopenharmony_ciASN1_BROKEN_SEQUENCE(NETSCAPE_ENCRYPTED_PKEY) = { 42e1051a39Sopenharmony_ci ASN1_SIMPLE(NETSCAPE_ENCRYPTED_PKEY, os, ASN1_OCTET_STRING), 43e1051a39Sopenharmony_ci ASN1_SIMPLE(NETSCAPE_ENCRYPTED_PKEY, enckey, X509_SIG) 44e1051a39Sopenharmony_ci} static_ASN1_BROKEN_SEQUENCE_END(NETSCAPE_ENCRYPTED_PKEY) 45e1051a39Sopenharmony_ci 46e1051a39Sopenharmony_ciDECLARE_ASN1_FUNCTIONS(NETSCAPE_ENCRYPTED_PKEY) 47e1051a39Sopenharmony_ciDECLARE_ASN1_ENCODE_FUNCTIONS_name(NETSCAPE_ENCRYPTED_PKEY, NETSCAPE_ENCRYPTED_PKEY) 48e1051a39Sopenharmony_ciIMPLEMENT_ASN1_FUNCTIONS(NETSCAPE_ENCRYPTED_PKEY) 49e1051a39Sopenharmony_ci 50e1051a39Sopenharmony_ciASN1_SEQUENCE(NETSCAPE_PKEY) = { 51e1051a39Sopenharmony_ci ASN1_EMBED(NETSCAPE_PKEY, version, INT32), 52e1051a39Sopenharmony_ci ASN1_SIMPLE(NETSCAPE_PKEY, algor, X509_ALGOR), 53e1051a39Sopenharmony_ci ASN1_SIMPLE(NETSCAPE_PKEY, private_key, ASN1_OCTET_STRING) 54e1051a39Sopenharmony_ci} static_ASN1_SEQUENCE_END(NETSCAPE_PKEY) 55e1051a39Sopenharmony_ci 56e1051a39Sopenharmony_ciDECLARE_ASN1_FUNCTIONS(NETSCAPE_PKEY) 57e1051a39Sopenharmony_ciDECLARE_ASN1_ENCODE_FUNCTIONS_name(NETSCAPE_PKEY, NETSCAPE_PKEY) 58e1051a39Sopenharmony_ciIMPLEMENT_ASN1_FUNCTIONS(NETSCAPE_PKEY) 59