Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 1 | /* |
Rich Salz | d2e9e32 | 2016-05-17 14:51:26 -0400 | [diff] [blame] | 2 | * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. |
Dr. Stephen Henson | 3d8accc | 1999-02-17 23:21:01 +0000 | [diff] [blame] | 3 | * |
Rich Salz | d2e9e32 | 2016-05-17 14:51:26 -0400 | [diff] [blame] | 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 |
Dr. Stephen Henson | 3d8accc | 1999-02-17 23:21:01 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <stdio.h> |
Richard Levitte | b39fc56 | 2015-05-14 16:56:48 +0200 | [diff] [blame] | 11 | #include "internal/cryptlib.h" |
Bodo Möller | ec57782 | 1999-04-23 22:13:45 +0000 | [diff] [blame] | 12 | #include <openssl/asn1.h> |
Dr. Stephen Henson | 9d6b1ce | 2000-12-08 19:09:35 +0000 | [diff] [blame] | 13 | #include <openssl/asn1t.h> |
Bodo Möller | ec57782 | 1999-04-23 22:13:45 +0000 | [diff] [blame] | 14 | #include <openssl/x509v3.h> |
Ben Laurie | df2ee0e | 2015-09-05 13:32:58 +0100 | [diff] [blame] | 15 | #include "ext_dat.h" |
Dr. Stephen Henson | 3d8accc | 1999-02-17 23:21:01 +0000 | [diff] [blame] | 16 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 17 | static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, |
| 18 | PKEY_USAGE_PERIOD *usage, BIO *out, |
| 19 | int indent); |
Matt Caswell | 7f517c2 | 2017-02-28 14:55:35 +0000 | [diff] [blame] | 20 | |
Dr. Stephen Henson | 560b79c | 2007-01-21 13:07:17 +0000 | [diff] [blame] | 21 | const X509V3_EXT_METHOD v3_pkey_usage_period = { |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 22 | 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 Henson | 3d8accc | 1999-02-17 23:21:01 +0000 | [diff] [blame] | 27 | }; |
| 28 | |
Dr. Stephen Henson | 9d6b1ce | 2000-12-08 19:09:35 +0000 | [diff] [blame] | 29 | ASN1_SEQUENCE(PKEY_USAGE_PERIOD) = { |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 30 | ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notBefore, ASN1_GENERALIZEDTIME, 0), |
| 31 | ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notAfter, ASN1_GENERALIZEDTIME, 1) |
Dr. Stephen Henson | d339187 | 2001-02-23 12:47:06 +0000 | [diff] [blame] | 32 | } ASN1_SEQUENCE_END(PKEY_USAGE_PERIOD) |
Dr. Stephen Henson | 3d8accc | 1999-02-17 23:21:01 +0000 | [diff] [blame] | 33 | |
Dr. Stephen Henson | 9d6b1ce | 2000-12-08 19:09:35 +0000 | [diff] [blame] | 34 | IMPLEMENT_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) |
Dr. Stephen Henson | 3d8accc | 1999-02-17 23:21:01 +0000 | [diff] [blame] | 35 | |
Ulf Möller | 6b691a5 | 1999-04-19 21:31:43 +0000 | [diff] [blame] | 36 | static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 37 | PKEY_USAGE_PERIOD *usage, BIO *out, |
| 38 | int indent) |
Dr. Stephen Henson | 3d8accc | 1999-02-17 23:21:01 +0000 | [diff] [blame] | 39 | { |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 40 | 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 Henson | 3d8accc | 1999-02-17 23:21:01 +0000 | [diff] [blame] | 52 | } |