155714Skris/* v3_pku.c */
2296341Sdelphij/*
3296341Sdelphij * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
4296341Sdelphij * 1999.
555714Skris */
655714Skris/* ====================================================================
755714Skris * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
855714Skris *
955714Skris * Redistribution and use in source and binary forms, with or without
1055714Skris * modification, are permitted provided that the following conditions
1155714Skris * are met:
1255714Skris *
1355714Skris * 1. Redistributions of source code must retain the above copyright
14296341Sdelphij *    notice, this list of conditions and the following disclaimer.
1555714Skris *
1655714Skris * 2. Redistributions in binary form must reproduce the above copyright
1755714Skris *    notice, this list of conditions and the following disclaimer in
1855714Skris *    the documentation and/or other materials provided with the
1955714Skris *    distribution.
2055714Skris *
2155714Skris * 3. All advertising materials mentioning features or use of this
2255714Skris *    software must display the following acknowledgment:
2355714Skris *    "This product includes software developed by the OpenSSL Project
2455714Skris *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
2555714Skris *
2655714Skris * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
2755714Skris *    endorse or promote products derived from this software without
2855714Skris *    prior written permission. For written permission, please contact
2955714Skris *    licensing@OpenSSL.org.
3055714Skris *
3155714Skris * 5. Products derived from this software may not be called "OpenSSL"
3255714Skris *    nor may "OpenSSL" appear in their names without prior written
3355714Skris *    permission of the OpenSSL Project.
3455714Skris *
3555714Skris * 6. Redistributions of any form whatsoever must retain the following
3655714Skris *    acknowledgment:
3755714Skris *    "This product includes software developed by the OpenSSL Project
3855714Skris *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
3955714Skris *
4055714Skris * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
4155714Skris * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4255714Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
4355714Skris * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
4455714Skris * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4555714Skris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
4655714Skris * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
4755714Skris * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4855714Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
4955714Skris * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
5055714Skris * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
5155714Skris * OF THE POSSIBILITY OF SUCH DAMAGE.
5255714Skris * ====================================================================
5355714Skris *
5455714Skris * This product includes cryptographic software written by Eric Young
5555714Skris * (eay@cryptsoft.com).  This product includes software written by Tim
5655714Skris * Hudson (tjh@cryptsoft.com).
5755714Skris *
5855714Skris */
5955714Skris
6055714Skris#include <stdio.h>
6155714Skris#include "cryptlib.h"
6255714Skris#include <openssl/asn1.h>
63109998Smarkm#include <openssl/asn1t.h>
6455714Skris#include <openssl/x509v3.h>
6555714Skris
66296341Sdelphijstatic int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method,
67296341Sdelphij                                 PKEY_USAGE_PERIOD *usage, BIO *out,
68296341Sdelphij                                 int indent);
6955714Skris/*
70296341Sdelphij * static PKEY_USAGE_PERIOD *v2i_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method,
71296341Sdelphij * X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values);
72296341Sdelphij */
73167612Ssimonconst X509V3_EXT_METHOD v3_pkey_usage_period = {
74296341Sdelphij    NID_private_key_usage_period, 0, ASN1_ITEM_ref(PKEY_USAGE_PERIOD),
75296341Sdelphij    0, 0, 0, 0,
76296341Sdelphij    0, 0, 0, 0,
77296341Sdelphij    (X509V3_EXT_I2R)i2r_PKEY_USAGE_PERIOD, NULL,
78296341Sdelphij    NULL
7955714Skris};
8055714Skris
81109998SmarkmASN1_SEQUENCE(PKEY_USAGE_PERIOD) = {
82296341Sdelphij        ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notBefore, ASN1_GENERALIZEDTIME, 0),
83296341Sdelphij        ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notAfter, ASN1_GENERALIZEDTIME, 1)
84109998Smarkm} ASN1_SEQUENCE_END(PKEY_USAGE_PERIOD)
8555714Skris
86109998SmarkmIMPLEMENT_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)
8755714Skris
8855714Skrisstatic int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method,
89296341Sdelphij                                 PKEY_USAGE_PERIOD *usage, BIO *out,
90296341Sdelphij                                 int indent)
9155714Skris{
92296341Sdelphij    BIO_printf(out, "%*s", indent, "");
93296341Sdelphij    if (usage->notBefore) {
94296341Sdelphij        BIO_write(out, "Not Before: ", 12);
95296341Sdelphij        ASN1_GENERALIZEDTIME_print(out, usage->notBefore);
96296341Sdelphij        if (usage->notAfter)
97296341Sdelphij            BIO_write(out, ", ", 2);
98296341Sdelphij    }
99296341Sdelphij    if (usage->notAfter) {
100296341Sdelphij        BIO_write(out, "Not After: ", 11);
101296341Sdelphij        ASN1_GENERALIZEDTIME_print(out, usage->notAfter);
102296341Sdelphij    }
103296341Sdelphij    return 1;
10455714Skris}
10555714Skris
106296341Sdelphij/*-
10755714Skrisstatic PKEY_USAGE_PERIOD *v2i_PKEY_USAGE_PERIOD(method, ctx, values)
10855714SkrisX509V3_EXT_METHOD *method;
10955714SkrisX509V3_CTX *ctx;
11055714SkrisSTACK_OF(CONF_VALUE) *values;
11155714Skris{
11255714Skrisreturn NULL;
11355714Skris}
11455714Skris*/
115