blob: 5a7e7d972516f5bfb5c1e8e3b66264125d4e803e [file] [log] [blame]
Matt Caswell0f113f32015-01-22 03:40:55 +00001/*
Rich Salzd2e9e322016-05-17 14:51:26 -04002 * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
Dr. Stephen Henson3d8accc1999-02-17 23:21:01 +00003 *
Rich Salzd2e9e322016-05-17 14:51:26 -04004 * 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
Dr. Stephen Henson3d8accc1999-02-17 23:21:01 +00008 */
9
10#include <stdio.h>
Richard Levitteb39fc562015-05-14 16:56:48 +020011#include "internal/cryptlib.h"
Bodo Möllerec577821999-04-23 22:13:45 +000012#include <openssl/asn1.h>
Dr. Stephen Henson9d6b1ce2000-12-08 19:09:35 +000013#include <openssl/asn1t.h>
Bodo Möllerec577821999-04-23 22:13:45 +000014#include <openssl/x509v3.h>
Ben Lauriedf2ee0e2015-09-05 13:32:58 +010015#include "ext_dat.h"
Dr. Stephen Henson3d8accc1999-02-17 23:21:01 +000016
Matt Caswell0f113f32015-01-22 03:40:55 +000017static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method,
18 PKEY_USAGE_PERIOD *usage, BIO *out,
19 int indent);
Matt Caswell7f517c22017-02-28 14:55:35 +000020
Dr. Stephen Henson560b79c2007-01-21 13:07:17 +000021const X509V3_EXT_METHOD v3_pkey_usage_period = {
Matt Caswell0f113f32015-01-22 03:40:55 +000022 NID_private_key_usage_period, 0, ASN1_ITEM_ref(PKEY_USAGE_PERIOD),
23 0, 0, 0, 0,
24 0, 0, 0, 0,
25 (X509V3_EXT_I2R)i2r_PKEY_USAGE_PERIOD, NULL,
26 NULL
Dr. Stephen Henson3d8accc1999-02-17 23:21:01 +000027};
28
Dr. Stephen Henson9d6b1ce2000-12-08 19:09:35 +000029ASN1_SEQUENCE(PKEY_USAGE_PERIOD) = {
Matt Caswell0f113f32015-01-22 03:40:55 +000030 ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notBefore, ASN1_GENERALIZEDTIME, 0),
31 ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notAfter, ASN1_GENERALIZEDTIME, 1)
Dr. Stephen Hensond3391872001-02-23 12:47:06 +000032} ASN1_SEQUENCE_END(PKEY_USAGE_PERIOD)
Dr. Stephen Henson3d8accc1999-02-17 23:21:01 +000033
Dr. Stephen Henson9d6b1ce2000-12-08 19:09:35 +000034IMPLEMENT_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)
Dr. Stephen Henson3d8accc1999-02-17 23:21:01 +000035
Ulf Möller6b691a51999-04-19 21:31:43 +000036static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method,
Matt Caswell0f113f32015-01-22 03:40:55 +000037 PKEY_USAGE_PERIOD *usage, BIO *out,
38 int indent)
Dr. Stephen Henson3d8accc1999-02-17 23:21:01 +000039{
Matt Caswell0f113f32015-01-22 03:40:55 +000040 BIO_printf(out, "%*s", indent, "");
41 if (usage->notBefore) {
42 BIO_write(out, "Not Before: ", 12);
43 ASN1_GENERALIZEDTIME_print(out, usage->notBefore);
44 if (usage->notAfter)
45 BIO_write(out, ", ", 2);
46 }
47 if (usage->notAfter) {
48 BIO_write(out, "Not After: ", 11);
49 ASN1_GENERALIZEDTIME_print(out, usage->notAfter);
50 }
51 return 1;
Dr. Stephen Henson3d8accc1999-02-17 23:21:01 +000052}