summaryrefslogtreecommitdiffstats
path: root/crypto/der_writer.c
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2020-08-04 12:18:51 +1000
committerShane Lontis <shane.lontis@oracle.com>2020-08-04 12:18:51 +1000
commite5b2cd5899b2631363740a40c76d96fd15d32d1c (patch)
tree4953c2a16f26c0c890725b7d576f7cb43b1c8ead /crypto/der_writer.c
parent37d898df348b87a423133afdbb828383be22fda7 (diff)
Change the provider implementation of X942kdf to use wpacket to do der encoding of sharedInfo
Added der_writer functions for writing octet string primitives. Generate OID's for key wrapping algorithms used by X942 KDF. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12554)
Diffstat (limited to 'crypto/der_writer.c')
-rw-r--r--crypto/der_writer.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/crypto/der_writer.c b/crypto/der_writer.c
index 117b5dff90..8210327f06 100644
--- a/crypto/der_writer.c
+++ b/crypto/der_writer.c
@@ -66,6 +66,29 @@ int DER_w_boolean(WPACKET *pkt, int tag, int b)
&& int_end_context(pkt, tag);
}
+int DER_w_octet_string(WPACKET *pkt, int tag,
+ const unsigned char *data, size_t data_n)
+{
+ return int_start_context(pkt, tag)
+ && WPACKET_start_sub_packet(pkt)
+ && WPACKET_memcpy(pkt, data, data_n)
+ && WPACKET_close(pkt)
+ && WPACKET_put_bytes_u8(pkt, DER_P_OCTET_STRING)
+ && int_end_context(pkt, tag);
+}
+
+int DER_w_octet_string_uint32(WPACKET *pkt, int tag, uint32_t value)
+{
+ unsigned char tmp[4] = { 0, 0, 0, 0 };
+ unsigned char *pbuf = tmp + (sizeof(tmp) - 1);
+
+ while (value > 0) {
+ *pbuf-- = (value & 0xFF);
+ value >>= 8;
+ }
+ return DER_w_octet_string(pkt, tag, tmp, sizeof(tmp));
+}
+
static int int_der_w_integer(WPACKET *pkt, int tag,
int (*put_bytes)(WPACKET *pkt, const void *v,
unsigned int *top_byte),