sync with OpenBSD -current

This commit is contained in:
purplerain 2024-05-30 15:25:45 +00:00
parent 222e583e28
commit 2d58860211
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
41 changed files with 532 additions and 277 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: a_object.c,v 1.51 2023/07/05 21:23:36 beck Exp $ */
/* $OpenBSD: a_object.c,v 1.54 2024/05/29 16:14:38 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -615,23 +615,34 @@ c2i_ASN1_OBJECT(ASN1_OBJECT **out_aobj, const unsigned char **pp, long len)
int
i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp)
{
unsigned char *p;
unsigned char *buf, *p;
int objsize;
if ((a == NULL) || (a->data == NULL))
return (0);
if (a == NULL || a->data == NULL)
return -1;
objsize = ASN1_object_size(0, a->length, V_ASN1_OBJECT);
if (pp == NULL)
return objsize;
p = *pp;
if ((buf = *pp) == NULL)
buf = calloc(1, objsize);
if (buf == NULL)
return -1;
p = buf;
ASN1_put_object(&p, 0, a->length, V_ASN1_OBJECT, V_ASN1_UNIVERSAL);
memcpy(p, a->data, a->length);
p += a->length;
/* If buf was allocated, return it, otherwise return the advanced p. */
if (*pp == NULL)
p = buf;
*pp = p;
return (objsize);
return objsize;
}
LCRYPTO_ALIAS(i2d_ASN1_OBJECT);