#include <stdio.h>
#include "cryptlib.h"
-#include "asn1.h"
-#include "asn1_mac.h"
-#include "x509v3.h"
+#include <openssl/asn1.h>
+#include <openssl/asn1t.h>
+#include <openssl/x509v3.h>
-#ifndef NOPROTO
-static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, PKEY_USAGE_PERIOD *usage, BIO *out);
+static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, PKEY_USAGE_PERIOD *usage, BIO *out, int indent);
/*
-static PKEY_USAGE_PERIOD *v2i_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK *values);
+static PKEY_USAGE_PERIOD *v2i_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values);
*/
-#else
-
-static int i2r_PKEY_USAGE_PERIOD();
-static PKEY_USAGE_PERIOD *v2i_PKEY_USAGE_PERIOD();
-
-#endif
-
X509V3_EXT_METHOD v3_pkey_usage_period = {
-NID_private_key_usage_period, 0,
-(X509V3_EXT_NEW)PKEY_USAGE_PERIOD_new,
-PKEY_USAGE_PERIOD_free,
-(X509V3_EXT_D2I)d2i_PKEY_USAGE_PERIOD,
-i2d_PKEY_USAGE_PERIOD,
-NULL, NULL, NULL, NULL,
-(X509V3_EXT_I2R)i2r_PKEY_USAGE_PERIOD,
+NID_private_key_usage_period, 0, ASN1_ITEM_ref(PKEY_USAGE_PERIOD),
+0,0,0,0,
+0,0,0,0,
+(X509V3_EXT_I2R)i2r_PKEY_USAGE_PERIOD, NULL,
NULL
};
+ASN1_SEQUENCE(PKEY_USAGE_PERIOD) = {
+ ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notBefore, ASN1_GENERALIZEDTIME, 0),
+ ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notAfter, ASN1_GENERALIZEDTIME, 1)
+} ASN1_SEQUENCE_END(PKEY_USAGE_PERIOD)
-/*
- * ASN1err(ASN1_F_PKEY_USAGE_PERIOD_NEW,ERR_R_MALLOC_FAILURE);
- * ASN1err(ASN1_F_D2I_PKEY_USAGE_PERIOD,ERR_R_MALLOC_FAILURE);
- */
-
-int i2d_PKEY_USAGE_PERIOD(a,pp)
-PKEY_USAGE_PERIOD *a;
-unsigned char **pp;
-{
- M_ASN1_I2D_vars(a);
-
- M_ASN1_I2D_len_IMP_opt (a->notBefore, i2d_ASN1_GENERALIZEDTIME);
- M_ASN1_I2D_len_IMP_opt (a->notAfter, i2d_ASN1_GENERALIZEDTIME);
-
- M_ASN1_I2D_seq_total();
-
- M_ASN1_I2D_put_IMP_opt (a->notBefore, i2d_ASN1_GENERALIZEDTIME, 0);
- M_ASN1_I2D_put_IMP_opt (a->notAfter, i2d_ASN1_GENERALIZEDTIME, 1);
-
- M_ASN1_I2D_finish();
-}
-
-PKEY_USAGE_PERIOD *PKEY_USAGE_PERIOD_new()
-{
- PKEY_USAGE_PERIOD *ret=NULL;
- ASN1_CTX c;
- M_ASN1_New_Malloc(ret, PKEY_USAGE_PERIOD);
- ret->notBefore = NULL;
- ret->notAfter = NULL;
- return (ret);
- M_ASN1_New_Error(ASN1_F_PKEY_USAGE_PERIOD_NEW);
-}
+IMPLEMENT_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)
-PKEY_USAGE_PERIOD *d2i_PKEY_USAGE_PERIOD(a,pp,length)
-PKEY_USAGE_PERIOD **a;
-unsigned char **pp;
-long length;
-{
- M_ASN1_D2I_vars(a,PKEY_USAGE_PERIOD *,PKEY_USAGE_PERIOD_new);
- M_ASN1_D2I_Init();
- M_ASN1_D2I_start_sequence();
- M_ASN1_D2I_get_IMP_opt (ret->notBefore, d2i_ASN1_GENERALIZEDTIME, 0,
- V_ASN1_GENERALIZEDTIME);
- M_ASN1_D2I_get_IMP_opt (ret->notAfter, d2i_ASN1_GENERALIZEDTIME, 1,
- V_ASN1_GENERALIZEDTIME);
- M_ASN1_D2I_Finish(a, PKEY_USAGE_PERIOD_free, ASN1_F_D2I_PKEY_USAGE_PERIOD);
-}
-
-void PKEY_USAGE_PERIOD_free(a)
-PKEY_USAGE_PERIOD *a;
-{
- if (a == NULL) return;
- ASN1_GENERALIZEDTIME_free(a->notBefore);
- ASN1_GENERALIZEDTIME_free(a->notAfter);
- Free ((char *)a);
-}
-
-static int i2r_PKEY_USAGE_PERIOD(method, usage, out)
-X509V3_EXT_METHOD *method;
-PKEY_USAGE_PERIOD *usage;
-BIO *out;
+static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method,
+ PKEY_USAGE_PERIOD *usage, BIO *out, int indent)
{
+ BIO_printf(out, "%*s", indent, "");
if(usage->notBefore) {
BIO_write(out, "Not Before: ", 12);
ASN1_GENERALIZEDTIME_print(out, usage->notBefore);
static PKEY_USAGE_PERIOD *v2i_PKEY_USAGE_PERIOD(method, ctx, values)
X509V3_EXT_METHOD *method;
X509V3_CTX *ctx;
-STACK *values;
+STACK_OF(CONF_VALUE) *values;
{
return NULL;
}