1e1051a39Sopenharmony_ci/* 2e1051a39Sopenharmony_ci * Copyright 1999-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 <stdio.h> 11e1051a39Sopenharmony_ci#include "internal/cryptlib.h" 12e1051a39Sopenharmony_ci#include <openssl/asn1.h> 13e1051a39Sopenharmony_ci#include <openssl/asn1t.h> 14e1051a39Sopenharmony_ci#include <openssl/x509v3.h> 15e1051a39Sopenharmony_ci#include "ext_dat.h" 16e1051a39Sopenharmony_ci 17e1051a39Sopenharmony_cistatic int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, 18e1051a39Sopenharmony_ci PKEY_USAGE_PERIOD *usage, BIO *out, 19e1051a39Sopenharmony_ci int indent); 20e1051a39Sopenharmony_ci 21e1051a39Sopenharmony_ciconst X509V3_EXT_METHOD ossl_v3_pkey_usage_period = { 22e1051a39Sopenharmony_ci NID_private_key_usage_period, 0, ASN1_ITEM_ref(PKEY_USAGE_PERIOD), 23e1051a39Sopenharmony_ci 0, 0, 0, 0, 24e1051a39Sopenharmony_ci 0, 0, 0, 0, 25e1051a39Sopenharmony_ci (X509V3_EXT_I2R)i2r_PKEY_USAGE_PERIOD, NULL, 26e1051a39Sopenharmony_ci NULL 27e1051a39Sopenharmony_ci}; 28e1051a39Sopenharmony_ci 29e1051a39Sopenharmony_ciASN1_SEQUENCE(PKEY_USAGE_PERIOD) = { 30e1051a39Sopenharmony_ci ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notBefore, ASN1_GENERALIZEDTIME, 0), 31e1051a39Sopenharmony_ci ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notAfter, ASN1_GENERALIZEDTIME, 1) 32e1051a39Sopenharmony_ci} ASN1_SEQUENCE_END(PKEY_USAGE_PERIOD) 33e1051a39Sopenharmony_ci 34e1051a39Sopenharmony_ciIMPLEMENT_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) 35e1051a39Sopenharmony_ci 36e1051a39Sopenharmony_cistatic int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, 37e1051a39Sopenharmony_ci PKEY_USAGE_PERIOD *usage, BIO *out, 38e1051a39Sopenharmony_ci int indent) 39e1051a39Sopenharmony_ci{ 40e1051a39Sopenharmony_ci BIO_printf(out, "%*s", indent, ""); 41e1051a39Sopenharmony_ci if (usage->notBefore) { 42e1051a39Sopenharmony_ci BIO_write(out, "Not Before: ", 12); 43e1051a39Sopenharmony_ci ASN1_GENERALIZEDTIME_print(out, usage->notBefore); 44e1051a39Sopenharmony_ci if (usage->notAfter) 45e1051a39Sopenharmony_ci BIO_write(out, ", ", 2); 46e1051a39Sopenharmony_ci } 47e1051a39Sopenharmony_ci if (usage->notAfter) { 48e1051a39Sopenharmony_ci BIO_write(out, "Not After: ", 11); 49e1051a39Sopenharmony_ci ASN1_GENERALIZEDTIME_print(out, usage->notAfter); 50e1051a39Sopenharmony_ci } 51e1051a39Sopenharmony_ci return 1; 52e1051a39Sopenharmony_ci} 53