*
* Returns 1 on success or 0 on failure.
*/
-int decode_der_length(PACKET *pkt, PACKET *subpkt)
+int ossl_decode_der_length(PACKET *pkt, PACKET *subpkt)
{
unsigned int byte;
* trailing garbage then it is up to the caller to verify that all bytes
* were consumed.
*/
-int decode_der_integer(PACKET *pkt, BIGNUM *n)
+int ossl_decode_der_integer(PACKET *pkt, BIGNUM *n)
{
PACKET contpkt, tmppkt;
unsigned int tag, tmp;
/* Check we have an integer and get the content bytes */
if (!PACKET_get_1(pkt, &tag)
|| tag != ID_INTEGER
- || !decode_der_length(pkt, &contpkt))
+ || !ossl_decode_der_length(pkt, &contpkt))
return 0;
/* Peek ahead at the first bytes to check for proper encoding */
* trailing garbage then it is up to the caller to verify that all bytes
* were consumed.
*/
-size_t decode_der_dsa_sig(BIGNUM *r, BIGNUM *s, const unsigned char **ppin,
- size_t len)
+size_t ossl_decode_der_dsa_sig(BIGNUM *r, BIGNUM *s,
+ const unsigned char **ppin, size_t len)
{
size_t consumed;
PACKET pkt, contpkt;
if (!PACKET_buf_init(&pkt, *ppin, len)
|| !PACKET_get_1(&pkt, &tag)
|| tag != ID_SEQUENCE
- || !decode_der_length(&pkt, &contpkt)
- || !decode_der_integer(&contpkt, r)
- || !decode_der_integer(&contpkt, s)
+ || !ossl_decode_der_length(&pkt, &contpkt)
+ || !ossl_decode_der_integer(&contpkt, r)
+ || !ossl_decode_der_integer(&contpkt, s)
|| PACKET_remaining(&contpkt) != 0)
return 0;
&& (size1 == size2 || WPACKET_put_bytes_u8(pkt, tag));
}
-int DER_w_precompiled(WPACKET *pkt, int tag,
- const unsigned char *precompiled, size_t precompiled_n)
+int ossl_DER_w_precompiled(WPACKET *pkt, int tag,
+ const unsigned char *precompiled,
+ size_t precompiled_n)
{
return int_start_context(pkt, tag)
&& WPACKET_memcpy(pkt, precompiled, precompiled_n)
&& int_end_context(pkt, tag);
}
-int DER_w_boolean(WPACKET *pkt, int tag, int b)
+int ossl_DER_w_boolean(WPACKET *pkt, int tag, int b)
{
return int_start_context(pkt, tag)
&& WPACKET_start_sub_packet(pkt)
&& int_end_context(pkt, tag);
}
-int DER_w_octet_string(WPACKET *pkt, int tag,
- const unsigned char *data, size_t data_n)
+int ossl_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)
&& int_end_context(pkt, tag);
}
-int DER_w_octet_string_uint32(WPACKET *pkt, int tag, uint32_t value)
+int ossl_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);
*pbuf-- = (value & 0xFF);
value >>= 8;
}
- return DER_w_octet_string(pkt, tag, tmp, sizeof(tmp));
+ return ossl_DER_w_octet_string(pkt, tag, tmp, sizeof(tmp));
}
static int int_der_w_integer(WPACKET *pkt, int tag,
}
/* For integers, we only support unsigned values for now */
-int DER_w_ulong(WPACKET *pkt, int tag, unsigned long v)
+int ossl_DER_w_ulong(WPACKET *pkt, int tag, unsigned long v)
{
return int_der_w_integer(pkt, tag, int_put_bytes_ulong, &v);
}
return 1;
}
-int DER_w_bn(WPACKET *pkt, int tag, const BIGNUM *v)
+int ossl_DER_w_bn(WPACKET *pkt, int tag, const BIGNUM *v)
{
if (v == NULL || BN_is_negative(v))
return 0;
if (BN_is_zero(v))
- return DER_w_ulong(pkt, tag, 0);
+ return ossl_DER_w_ulong(pkt, tag, 0);
return int_der_w_integer(pkt, tag, int_put_bytes_bn, v);
}
-int DER_w_null(WPACKET *pkt, int tag)
+int ossl_DER_w_null(WPACKET *pkt, int tag)
{
return int_start_context(pkt, tag)
&& WPACKET_start_sub_packet(pkt)
}
/* Constructed things need a start and an end */
-int DER_w_begin_sequence(WPACKET *pkt, int tag)
+int ossl_DER_w_begin_sequence(WPACKET *pkt, int tag)
{
return int_start_context(pkt, tag)
&& WPACKET_start_sub_packet(pkt);
}
-int DER_w_end_sequence(WPACKET *pkt, int tag)
+int ossl_DER_w_end_sequence(WPACKET *pkt, int tag)
{
/*
* If someone set the flag WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH on this
sig->r = BN_new();
if (sig->s == NULL)
sig->s = BN_new();
- if (decode_der_dsa_sig(sig->r, sig->s, ppin, (size_t)len) == 0) {
+ if (ossl_decode_der_dsa_sig(sig->r, sig->s, ppin, (size_t)len) == 0) {
if (psig == NULL || *psig == NULL)
DSA_SIG_free(sig);
return NULL;
sig->r = BN_new();
if (sig->s == NULL)
sig->s = BN_new();
- if (decode_der_dsa_sig(sig->r, sig->s, ppin, (size_t)len) == 0) {
+ if (ossl_decode_der_dsa_sig(sig->r, sig->s, ppin, (size_t)len) == 0) {
if (psig == NULL || *psig == NULL)
ECDSA_SIG_free(sig);
return NULL;
=head1 NAME
-DER_w_begin_sequence, DER_w_end_sequence
+ossl_DER_w_begin_sequence, ossl_DER_w_end_sequence
- internal DER writers for DER constructed elements
=head1 SYNOPSIS
#include "internal/der.h"
- int DER_w_begin_sequence(WPACKET *pkt, int tag);
- int DER_w_end_sequence(WPACKET *pkt, int tag);
+ int ossl_DER_w_begin_sequence(WPACKET *pkt, int tag);
+ int ossl_DER_w_end_sequence(WPACKET *pkt, int tag);
=head1 DESCRIPTION
When using these, special care must be taken to ensure that the ASN.1 tag
value I<tag> is the same in the matching C<begin> and C<end> function calls.
-DER_w_begin_sequence() and DER_w_end_sequence() begins and ends a
+ossl_DER_w_begin_sequence() and ossl_DER_w_end_sequence() begins and ends a
SEQUENCE.
=head1 RETURN VALUES
=head1 NAME
-DER_w_boolean, DER_w_ulong, DER_w_bn, DER_w_null,
-DER_w_octet_string, DER_w_octet_string_uint32
+ossl_DER_w_boolean, ossl_DER_w_ulong, ossl_DER_w_bn, ossl_DER_w_null,
+ossl_DER_w_octet_string, ossl_DER_w_octet_string_uint32
- internal DER writers for DER primitives
=head1 SYNOPSIS
#include "internal/der.h"
- int DER_w_boolean(WPACKET *pkt, int tag, int b);
- int DER_w_ulong(WPACKET *pkt, int tag, unsigned long v);
- int DER_w_bn(WPACKET *pkt, int tag, const BIGNUM *v);
- int DER_w_null(WPACKET *pkt, int tag);
- int DER_w_octet_string(WPACKET *pkt, int tag,
- const unsigned char *data, size_t data_n);
- int DER_w_octet_string_uint32(WPACKET *pkt, int tag, uint32_t value);
+ int ossl_DER_w_boolean(WPACKET *pkt, int tag, int b);
+ int ossl_DER_w_ulong(WPACKET *pkt, int tag, unsigned long v);
+ int ossl_DER_w_bn(WPACKET *pkt, int tag, const BIGNUM *v);
+ int ossl_DER_w_null(WPACKET *pkt, int tag);
+ int ossl_DER_w_octet_string(WPACKET *pkt, int tag,
+ const unsigned char *data, size_t data_n);
+ int ossl_DER_w_octet_string_uint32(WPACKET *pkt, int tag, uint32_t value);
=head1 DESCRIPTION
their respective value to the already written output buffer held by
I<pkt>.
-DER_w_boolean() writes the primitive BOOLEAN using the value I<b>.
+ossl_DER_w_boolean() writes the primitive BOOLEAN using the value I<b>.
Any value that evaluates as true will render a B<true> BOOLEAN,
otherwise a B<false> BOOLEAN.
-DER_w_ulong() and DER_w_bn() both write the primitive INTEGER using
+ossl_DER_w_ulong() and ossl_DER_w_bn() both write the primitive INTEGER using
the value I<v>.
=for comment Other similar functions for diverse C integers should be
added.
-DER_w_null() writes the primitive NULL.
+ossl_DER_w_null() writes the primitive NULL.
-DER_w_octet_string() writes the primitive OCTET STRING using the bytes from
-I<data> with a length of I<data_n>.
+ossl_DER_w_octet_string() writes the primitive OCTET STRING using the bytes
+from I<data> with a length of I<data_n>.
-DER_w_octet_string_uint32() writes the primitive OCTET STRING using a 32 bit
-value in I<value>.
+ossl_DER_w_octet_string_uint32() writes the primitive OCTET STRING using a
+32 bit value in I<value>.
=head1 RETURN VALUES
=head1 NAME
-DER_w_precompiled
+ossl_DER_w_precompiled
- internal DER writers for precompiled DER blobs
=head1 SYNOPSIS
#include "internal/der.h"
- int DER_w_precompiled(WPACKET *pkt, int tag,
- const unsigned char *precompiled,
- size_t precompiled_n);
+ int ossl_DER_w_precompiled(WPACKET *pkt, int tag,
+ const unsigned char *precompiled,
+ size_t precompiled_n);
=head1 DESCRIPTION
the buffer held by I<pkt>. For example, precompiled values, such as
OIDs (for example, C<id-sha256>) or complete AlgorithmIdentifiers
(for example, C<sha256Identifier>). To add those as an element in a
-structure being DER encoded, use DER_w_precompiled().
+structure being DER encoded, use ossl_DER_w_precompiled().
-DER_w_precompiled() will simply take the DER encoded blob given as
+ossl_DER_w_precompiled() will simply take the DER encoded blob given as
I<precompiled> with length I<precompiled_n> and add it to the buffer
held by I<pkt>.
=head1 RETURN VALUES
-DER_w_precompiled() returns 1 on success and 0 on failure. Failure
+ossl_DER_w_precompiled() returns 1 on success and 0 on failure. Failure
may mean that the buffer held by the I<pkt> is too small, but may also
mean that the values given to the functions are invalid, such as the provided
I<tag> value being too large for the implementation.
With the DER library, this is the corresponding code, given two OpenSSL
B<BIGNUM>s I<r> and I<s>:
- int ok = DER_w_begin_sequence(pkt, -1)
- && DER_w_bn(pkg, -1, s)
- && DER_w_bn(pkg, -1, r)
- && DER_w_end_sequence(pkt, -1);
+ int ok = ossl_DER_w_begin_sequence(pkt, -1)
+ && ossl_DER_w_bn(pkg, -1, s)
+ && ossl_DER_w_bn(pkg, -1, r)
+ && ossl_DER_w_end_sequence(pkt, -1);
As an example of the use of I<tag>, an ASN.1 element like this:
Would be encoded like this:
- DER_w_bn(pkt, 1, v)
+ ossl_DER_w_bn(pkt, 1, v)
=begin comment
int tag,
RSA *rsa)
{
- return DER_w_begin_sequence(pkt, tag)
- && (DER_w_begin_sequence(pkt, DER_NO_CONTEXT)
- && DER_w_ulong(pkt, 2, 20)
- && DER_w_precompiled(pkt, 1,
- der_mgf1SHA256Identifier,
- sizeof(der_mgf1SHA256Identifier))
- && DER_w_precompiled(pkt, 0,
- der_sha256Identifier,
- sizeof(der_sha256Identifier))
- && DER_w_end_sequence(pkt, DER_NO_CONTEXT))
- && DER_w_precompiled(pkt, DER_NO_CONTEXT,
- der_id_RSASSA_PSS,
- sizeof(der_id_RSASSA_PSS))
- && DER_w_end_sequence(pkt, tag);
+ return ossl_DER_w_begin_sequence(pkt, tag)
+ && (ossl_DER_w_begin_sequence(pkt, DER_NO_CONTEXT)
+ && ossl_DER_w_ulong(pkt, 2, 20)
+ && ossl_DER_w_precompiled(pkt, 1,
+ der_mgf1SHA256Identifier,
+ sizeof(der_mgf1SHA256Identifier))
+ && ossl_DER_w_precompiled(pkt, 0,
+ der_sha256Identifier,
+ sizeof(der_sha256Identifier))
+ && ossl_DER_w_end_sequence(pkt, DER_NO_CONTEXT))
+ && ossl_DER_w_precompiled(pkt, DER_NO_CONTEXT,
+ der_id_RSASSA_PSS,
+ sizeof(der_id_RSASSA_PSS))
+ && ossl_DER_w_end_sequence(pkt, tag);
}
=head1 SEE ALSO
-L<DER_w_bn(3)>, L<DER_w_begin_sequence(3)>, L<DER_w_precompiled(3)>
+L<ossl_DER_w_bn(3)>, L<ossl_DER_w_begin_sequence(3)>,
+L<ossl_DER_w_precompiled(3)>
=head1 COPYRIGHT
int encode_der_length(WPACKET *pkt, size_t cont_len);
int encode_der_integer(WPACKET *pkt, const BIGNUM *n);
int encode_der_dsa_sig(WPACKET *pkt, const BIGNUM *r, const BIGNUM *s);
-int decode_der_length(PACKET *pkt, PACKET *subpkt);
-int decode_der_integer(PACKET *pkt, BIGNUM *n);
-size_t decode_der_dsa_sig(BIGNUM *r, BIGNUM *s, const unsigned char **ppin,
- size_t len);
+int ossl_decode_der_length(PACKET *pkt, PACKET *subpkt);
+int ossl_decode_der_integer(PACKET *pkt, BIGNUM *n);
+size_t ossl_decode_der_dsa_sig(BIGNUM *r, BIGNUM *s, const unsigned char **ppin,
+ size_t len);
#endif
/* This can be used for all items that don't have a context */
#define DER_NO_CONTEXT -1
-int DER_w_precompiled(WPACKET *pkt, int tag,
- const unsigned char *precompiled, size_t precompiled_n);
+int ossl_DER_w_precompiled(WPACKET *pkt, int tag,
+ const unsigned char *precompiled,
+ size_t precompiled_n);
-int DER_w_boolean(WPACKET *pkt, int tag, int b);
-int DER_w_ulong(WPACKET *pkt, int tag, unsigned long v);
-int DER_w_bn(WPACKET *pkt, int tag, const BIGNUM *v);
-int DER_w_null(WPACKET *pkt, int tag);
-int DER_w_octet_string(WPACKET *pkt, int tag,
- const unsigned char *data, size_t data_n);
-int DER_w_octet_string_uint32(WPACKET *pkt, int tag, uint32_t value);
+int ossl_DER_w_boolean(WPACKET *pkt, int tag, int b);
+int ossl_DER_w_ulong(WPACKET *pkt, int tag, unsigned long v);
+int ossl_DER_w_bn(WPACKET *pkt, int tag, const BIGNUM *v);
+int ossl_DER_w_null(WPACKET *pkt, int tag);
+int ossl_DER_w_octet_string(WPACKET *pkt, int tag,
+ const unsigned char *data, size_t data_n);
+int ossl_DER_w_octet_string_uint32(WPACKET *pkt, int tag, uint32_t value);
/*
* All constructors for constructed elements have a begin and a end function
*/
-int DER_w_begin_sequence(WPACKET *pkt, int tag);
-int DER_w_end_sequence(WPACKET *pkt, int tag);
+int ossl_DER_w_begin_sequence(WPACKET *pkt, int tag);
+int ossl_DER_w_end_sequence(WPACKET *pkt, int tag);
-}
/* Subject Public Key Info */
-int DER_w_algorithmIdentifier_DSA(WPACKET *pkt, int tag, DSA *dsa);
+int ossl_DER_w_algorithmIdentifier_DSA(WPACKET *pkt, int tag, DSA *dsa);
/* Signature */
-int DER_w_algorithmIdentifier_DSA_with_MD(WPACKET *pkt, int tag,
- DSA *dsa, int mdnid);
+int ossl_DER_w_algorithmIdentifier_DSA_with_MD(WPACKET *pkt, int tag,
+ DSA *dsa, int mdnid);
#include "internal/packet.h"
#include "prov/der_dsa.h"
-int DER_w_algorithmIdentifier_DSA(WPACKET *pkt, int tag, DSA *dsa)
+int ossl_DER_w_algorithmIdentifier_DSA(WPACKET *pkt, int tag, DSA *dsa)
{
- return DER_w_begin_sequence(pkt, tag)
+ return ossl_DER_w_begin_sequence(pkt, tag)
/* No parameters (yet?) */
- && DER_w_precompiled(pkt, -1, der_oid_id_dsa, sizeof(der_oid_id_dsa))
- && DER_w_end_sequence(pkt, tag);
+ && ossl_DER_w_precompiled(pkt, -1, der_oid_id_dsa,
+ sizeof(der_oid_id_dsa))
+ && ossl_DER_w_end_sequence(pkt, tag);
}
precompiled_sz = sizeof(der_oid_id_dsa_with_##name); \
break;
-int DER_w_algorithmIdentifier_DSA_with_MD(WPACKET *pkt, int tag,
- DSA *dsa, int mdnid)
+int ossl_DER_w_algorithmIdentifier_DSA_with_MD(WPACKET *pkt, int tag,
+ DSA *dsa, int mdnid)
{
const unsigned char *precompiled = NULL;
size_t precompiled_sz = 0;
return 0;
}
- return DER_w_begin_sequence(pkt, tag)
+ return ossl_DER_w_begin_sequence(pkt, tag)
/* No parameters (yet?) */
- && DER_w_precompiled(pkt, -1, precompiled, precompiled_sz)
- && DER_w_end_sequence(pkt, tag);
+ && ossl_DER_w_precompiled(pkt, -1, precompiled, precompiled_sz)
+ && ossl_DER_w_end_sequence(pkt, tag);
}
-}
/* Subject Public Key Info */
-int DER_w_algorithmIdentifier_EC(WPACKET *pkt, int cont, EC_KEY *ec);
+int ossl_DER_w_algorithmIdentifier_EC(WPACKET *pkt, int cont, EC_KEY *ec);
/* Signature */
-int DER_w_algorithmIdentifier_ECDSA_with_MD(WPACKET *pkt, int cont,
- EC_KEY *ec, int mdnid);
+int ossl_DER_w_algorithmIdentifier_ECDSA_with_MD(WPACKET *pkt, int cont,
+ EC_KEY *ec, int mdnid);
#include "internal/packet.h"
#include "prov/der_ec.h"
-int DER_w_algorithmIdentifier_EC(WPACKET *pkt, int cont, EC_KEY *ec)
+int ossl_DER_w_algorithmIdentifier_EC(WPACKET *pkt, int cont, EC_KEY *ec)
{
- return DER_w_begin_sequence(pkt, cont)
+ return ossl_DER_w_begin_sequence(pkt, cont)
/* No parameters (yet?) */
- && DER_w_precompiled(pkt, -1, der_oid_id_ecPublicKey,
- sizeof(der_oid_id_ecPublicKey))
- && DER_w_end_sequence(pkt, cont);
+ && ossl_DER_w_precompiled(pkt, -1, der_oid_id_ecPublicKey,
+ sizeof(der_oid_id_ecPublicKey))
+ && ossl_DER_w_end_sequence(pkt, cont);
}
precompiled_sz = sizeof(der_oid_id_ecdsa_with_##name); \
break;
-int DER_w_algorithmIdentifier_ECDSA_with_MD(WPACKET *pkt, int cont,
- EC_KEY *ec, int mdnid)
+int ossl_DER_w_algorithmIdentifier_ECDSA_with_MD(WPACKET *pkt, int cont,
+ EC_KEY *ec, int mdnid)
{
const unsigned char *precompiled = NULL;
size_t precompiled_sz = 0;
return 0;
}
- return DER_w_begin_sequence(pkt, cont)
+ return ossl_DER_w_begin_sequence(pkt, cont)
/* No parameters (yet?) */
- && DER_w_precompiled(pkt, -1, precompiled, precompiled_sz)
- && DER_w_end_sequence(pkt, cont);
+ && ossl_DER_w_precompiled(pkt, -1, precompiled, precompiled_sz)
+ && ossl_DER_w_end_sequence(pkt, cont);
}
filter => \&oids_to_c::filter_to_H });
-}
-int DER_w_algorithmIdentifier_ED25519(WPACKET *pkt, int cont, ECX_KEY *ec);
-int DER_w_algorithmIdentifier_ED448(WPACKET *pkt, int cont, ECX_KEY *ec);
-int DER_w_algorithmIdentifier_X25519(WPACKET *pkt, int cont, ECX_KEY *ec);
-int DER_w_algorithmIdentifier_X448(WPACKET *pkt, int cont, ECX_KEY *ec);
+int ossl_DER_w_algorithmIdentifier_ED25519(WPACKET *pkt, int cont, ECX_KEY *ec);
+int ossl_DER_w_algorithmIdentifier_ED448(WPACKET *pkt, int cont, ECX_KEY *ec);
+int ossl_DER_w_algorithmIdentifier_X25519(WPACKET *pkt, int cont, ECX_KEY *ec);
+int ossl_DER_w_algorithmIdentifier_X448(WPACKET *pkt, int cont, ECX_KEY *ec);
#include "internal/packet.h"
#include "prov/der_ecx.h"
-int DER_w_algorithmIdentifier_X25519(WPACKET *pkt, int cont, ECX_KEY *ec)
+int ossl_DER_w_algorithmIdentifier_X25519(WPACKET *pkt, int cont, ECX_KEY *ec)
{
- return DER_w_begin_sequence(pkt, cont)
+ return ossl_DER_w_begin_sequence(pkt, cont)
/* No parameters (yet?) */
- && DER_w_precompiled(pkt, -1, der_oid_id_X25519,
- sizeof(der_oid_id_X25519))
- && DER_w_end_sequence(pkt, cont);
+ && ossl_DER_w_precompiled(pkt, -1, der_oid_id_X25519,
+ sizeof(der_oid_id_X25519))
+ && ossl_DER_w_end_sequence(pkt, cont);
}
-int DER_w_algorithmIdentifier_X448(WPACKET *pkt, int cont, ECX_KEY *ec)
+int ossl_DER_w_algorithmIdentifier_X448(WPACKET *pkt, int cont, ECX_KEY *ec)
{
- return DER_w_begin_sequence(pkt, cont)
+ return ossl_DER_w_begin_sequence(pkt, cont)
/* No parameters (yet?) */
- && DER_w_precompiled(pkt, -1, der_oid_id_X448,
- sizeof(der_oid_id_X448))
- && DER_w_end_sequence(pkt, cont);
+ && ossl_DER_w_precompiled(pkt, -1, der_oid_id_X448,
+ sizeof(der_oid_id_X448))
+ && ossl_DER_w_end_sequence(pkt, cont);
}
-int DER_w_algorithmIdentifier_ED25519(WPACKET *pkt, int cont, ECX_KEY *ec)
+int ossl_DER_w_algorithmIdentifier_ED25519(WPACKET *pkt, int cont, ECX_KEY *ec)
{
- return DER_w_begin_sequence(pkt, cont)
+ return ossl_DER_w_begin_sequence(pkt, cont)
/* No parameters (yet?) */
- && DER_w_precompiled(pkt, -1, der_oid_id_Ed25519,
- sizeof(der_oid_id_Ed25519))
- && DER_w_end_sequence(pkt, cont);
+ && ossl_DER_w_precompiled(pkt, -1, der_oid_id_Ed25519,
+ sizeof(der_oid_id_Ed25519))
+ && ossl_DER_w_end_sequence(pkt, cont);
}
-int DER_w_algorithmIdentifier_ED448(WPACKET *pkt, int cont, ECX_KEY *ec)
+int ossl_DER_w_algorithmIdentifier_ED448(WPACKET *pkt, int cont, ECX_KEY *ec)
{
- return DER_w_begin_sequence(pkt, cont)
+ return ossl_DER_w_begin_sequence(pkt, cont)
/* No parameters (yet?) */
- && DER_w_precompiled(pkt, -1, der_oid_id_Ed448,
- sizeof(der_oid_id_Ed448))
- && DER_w_end_sequence(pkt, cont);
+ && ossl_DER_w_precompiled(pkt, -1, der_oid_id_Ed448,
+ sizeof(der_oid_id_Ed448))
+ && ossl_DER_w_end_sequence(pkt, cont);
}
-}
/* PSS parameters */
-int DER_w_RSASSA_PSS_params(WPACKET *pkt, int tag,
- const RSA_PSS_PARAMS_30 *pss);
+int ossl_DER_w_RSASSA_PSS_params(WPACKET *pkt, int tag,
+ const RSA_PSS_PARAMS_30 *pss);
/* Subject Public Key Info */
-int DER_w_algorithmIdentifier_RSA(WPACKET *pkt, int tag, RSA *rsa);
+int ossl_DER_w_algorithmIdentifier_RSA(WPACKET *pkt, int tag, RSA *rsa);
/* Signature */
-int DER_w_algorithmIdentifier_MDWithRSAEncryption(WPACKET *pkt, int tag,
- RSA *rsa, int mdnid);
+int ossl_DER_w_algorithmIdentifier_MDWithRSAEncryption(WPACKET *pkt, int tag,
+ RSA *rsa, int mdnid);
if (maskgenalg == NULL)
return 1;
- return DER_w_precompiled(pkt, tag, maskgenalg, maskgenalg_sz);
+ return ossl_DER_w_precompiled(pkt, tag, maskgenalg, maskgenalg_sz);
}
return 0;
}
var##_sz = sizeof(der_oid_id_##name); \
break;
-int DER_w_RSASSA_PSS_params(WPACKET *pkt, int tag, const RSA_PSS_PARAMS_30 *pss)
+int ossl_DER_w_RSASSA_PSS_params(WPACKET *pkt, int tag,
+ const RSA_PSS_PARAMS_30 *pss)
{
int hashalg_nid, default_hashalg_nid;
int saltlen, default_saltlen;
return 0;
}
- return DER_w_begin_sequence(pkt, tag)
+ return ossl_DER_w_begin_sequence(pkt, tag)
&& (trailerfield == default_trailerfield
- || DER_w_ulong(pkt, 3, trailerfield))
- && (saltlen == default_saltlen || DER_w_ulong(pkt, 2, saltlen))
+ || ossl_DER_w_ulong(pkt, 3, trailerfield))
+ && (saltlen == default_saltlen || ossl_DER_w_ulong(pkt, 2, saltlen))
&& DER_w_MaskGenAlgorithm(pkt, 1, pss)
&& (hashalg_nid == default_hashalg_nid
- || DER_w_precompiled(pkt, 0, hashalg, hashalg_sz))
- && DER_w_end_sequence(pkt, tag);
+ || ossl_DER_w_precompiled(pkt, 0, hashalg, hashalg_sz))
+ && ossl_DER_w_end_sequence(pkt, tag);
}
/* Aliases so we can have a uniform RSA_CASE */
var##_oid_sz = sizeof(der_oid_##name); \
break;
-int DER_w_algorithmIdentifier_RSA(WPACKET *pkt, int tag, RSA *rsa)
+int ossl_DER_w_algorithmIdentifier_RSA(WPACKET *pkt, int tag, RSA *rsa)
{
int rsa_nid = NID_undef;
const unsigned char *rsa_oid = NULL;
if (rsa_oid == NULL)
return 0;
- return DER_w_begin_sequence(pkt, tag)
+ return ossl_DER_w_begin_sequence(pkt, tag)
&& (rsa_nid != NID_rsassaPss
|| rsa_pss_params_30_is_unrestricted(pss_params)
- || DER_w_RSASSA_PSS_params(pkt, -1, pss_params))
- && DER_w_precompiled(pkt, -1, rsa_oid, rsa_oid_sz)
- && DER_w_end_sequence(pkt, tag);
+ || ossl_DER_w_RSASSA_PSS_params(pkt, -1, pss_params))
+ && ossl_DER_w_precompiled(pkt, -1, rsa_oid, rsa_oid_sz)
+ && ossl_DER_w_end_sequence(pkt, tag);
}
var##_sz = sizeof(der_oid_##name##WithRSAEncryption); \
break;
-int DER_w_algorithmIdentifier_MDWithRSAEncryption(WPACKET *pkt, int tag,
- RSA *rsa, int mdnid)
+int ossl_DER_w_algorithmIdentifier_MDWithRSAEncryption(WPACKET *pkt, int tag,
+ RSA *rsa, int mdnid)
{
const unsigned char *precompiled = NULL;
size_t precompiled_sz = 0;
return 0;
}
- return DER_w_begin_sequence(pkt, tag)
+ return ossl_DER_w_begin_sequence(pkt, tag)
/* No parameters (yet?) */
- && DER_w_precompiled(pkt, -1, precompiled, precompiled_sz)
- && DER_w_end_sequence(pkt, tag);
+ && ossl_DER_w_precompiled(pkt, -1, precompiled, precompiled_sz)
+ && ossl_DER_w_end_sequence(pkt, tag);
}
int DER_w_algorithmIdentifier_SM2(WPACKET *pkt, int cont, EC_KEY *ec)
{
- return DER_w_begin_sequence(pkt, cont)
+ return ossl_DER_w_begin_sequence(pkt, cont)
/* No parameters (yet?) */
/* It seems SM2 identifier is the same as id_ecPublidKey */
- && DER_w_precompiled(pkt, -1, der_oid_id_ecPublicKey,
- sizeof(der_oid_id_ecPublicKey))
- && DER_w_end_sequence(pkt, cont);
+ && ossl_DER_w_precompiled(pkt, -1, der_oid_id_ecPublicKey,
+ sizeof(der_oid_id_ecPublicKey))
+ && ossl_DER_w_end_sequence(pkt, cont);
}
return 0;
}
- return DER_w_begin_sequence(pkt, cont)
+ return ossl_DER_w_begin_sequence(pkt, cont)
/* No parameters (yet?) */
- && DER_w_precompiled(pkt, -1, precompiled, precompiled_sz)
- && DER_w_end_sequence(pkt, cont);
+ && ossl_DER_w_precompiled(pkt, -1, precompiled, precompiled_sz)
+ && ossl_DER_w_end_sequence(pkt, cont);
}
}
break;
}
- if (!DER_w_RSASSA_PSS_params(&pkt, -1, pss)
+ if (!ossl_DER_w_RSASSA_PSS_params(&pkt, -1, pss)
|| !WPACKET_finish(&pkt)
|| !WPACKET_get_total_written(&pkt, &str_sz))
goto err;
const unsigned char *der_oid, size_t der_oidlen,
unsigned char **pcounter)
{
- return DER_w_begin_sequence(pkt, -1)
+ return ossl_DER_w_begin_sequence(pkt, -1)
/* Store the initial value of 1 into the counter */
- && DER_w_octet_string_uint32(pkt, -1, 1)
+ && ossl_DER_w_octet_string_uint32(pkt, -1, 1)
/* Remember where we stored the counter in the buffer */
&& (pcounter == NULL
|| (*pcounter = WPACKET_get_curr(pkt)) != NULL)
- && DER_w_precompiled(pkt, -1, der_oid, der_oidlen)
- && DER_w_end_sequence(pkt, -1);
+ && ossl_DER_w_precompiled(pkt, -1, der_oid, der_oidlen)
+ && ossl_DER_w_end_sequence(pkt, -1);
}
static int der_encode_sharedinfo(WPACKET *pkt, unsigned char *buf, size_t buflen,
{
return (buf != NULL ? WPACKET_init_der(pkt, buf, buflen) :
WPACKET_init_null_der(pkt))
- && DER_w_begin_sequence(pkt, -1)
- && DER_w_octet_string_uint32(pkt, 2, keylen_bits)
- && (ukm == NULL || DER_w_octet_string(pkt, 0, ukm, ukmlen))
+ && ossl_DER_w_begin_sequence(pkt, -1)
+ && ossl_DER_w_octet_string_uint32(pkt, 2, keylen_bits)
+ && (ukm == NULL || ossl_DER_w_octet_string(pkt, 0, ukm, ukmlen))
&& DER_w_keyinfo(pkt, der_oid, der_oidlen, pcounter)
- && DER_w_end_sequence(pkt, -1)
+ && ossl_DER_w_end_sequence(pkt, -1)
&& WPACKET_finish(pkt);
}
*/
ctx->aid_len = 0;
if (WPACKET_init_der(&pkt, ctx->aid_buf, sizeof(ctx->aid_buf))
- && DER_w_algorithmIdentifier_DSA_with_MD(&pkt, -1, ctx->dsa,
- md_nid)
+ && ossl_DER_w_algorithmIdentifier_DSA_with_MD(&pkt, -1, ctx->dsa,
+ md_nid)
&& WPACKET_finish(&pkt)) {
WPACKET_get_total_written(&pkt, &ctx->aid_len);
ctx->aid = WPACKET_get_curr(&pkt);
*/
ctx->aid_len = 0;
if (WPACKET_init_der(&pkt, ctx->aid_buf, sizeof(ctx->aid_buf))
- && DER_w_algorithmIdentifier_ECDSA_with_MD(&pkt, -1, ctx->ec, md_nid)
+ && ossl_DER_w_algorithmIdentifier_ECDSA_with_MD(&pkt, -1, ctx->ec,
+ md_nid)
&& WPACKET_finish(&pkt)) {
WPACKET_get_total_written(&pkt, &ctx->aid_len);
ctx->aid = WPACKET_get_curr(&pkt);
ret = WPACKET_init_der(&pkt, peddsactx->aid_buf, sizeof(peddsactx->aid_buf));
switch (edkey->type) {
case ECX_KEY_TYPE_ED25519:
- ret = ret && DER_w_algorithmIdentifier_ED25519(&pkt, -1, edkey);
+ ret = ret && ossl_DER_w_algorithmIdentifier_ED25519(&pkt, -1, edkey);
break;
case ECX_KEY_TYPE_ED448:
- ret = ret && DER_w_algorithmIdentifier_ED448(&pkt, -1, edkey);
+ ret = ret && ossl_DER_w_algorithmIdentifier_ED448(&pkt, -1, edkey);
break;
default:
/* Should never happen */
*/
ctx->aid_len = 0;
if (WPACKET_init_der(&pkt, ctx->aid_buf, sizeof(ctx->aid_buf))
- && DER_w_algorithmIdentifier_MDWithRSAEncryption(&pkt, -1, ctx->rsa,
- md_nid)
+ && ossl_DER_w_algorithmIdentifier_MDWithRSAEncryption(&pkt, -1,
+ ctx->rsa,
+ md_nid)
&& WPACKET_finish(&pkt)) {
WPACKET_get_total_written(&pkt, &ctx->aid_len);
ctx->aid = WPACKET_get_curr(&pkt);
* The decoder doesn't need any identification or to be attached to
* any provider, since it's only used locally.
*/
- to_obj = ossl_decoder_from_dispatch(0, &der_to_obj_algorithm, NULL);
+ to_obj = ossl_decoder_from_dispatch(0, &ossl_der_to_obj_algorithm,
+ NULL);
if (to_obj == NULL)
goto err;
to_obj_inst = ossl_decoder_instance_new(to_obj, ctx->provctx);
{ 0, NULL }
};
-const OSSL_ALGORITHM der_to_obj_algorithm =
+const OSSL_ALGORITHM ossl_der_to_obj_algorithm =
{ "obj", NULL, der_to_obj_decoder_functions };
* https://www.openssl.org/source/license.html
*/
-extern const OSSL_ALGORITHM der_to_obj_algorithm;
+extern const OSSL_ALGORITHM ossl_der_to_obj_algorithm;
/* Positive tests */
pder = t_dsa_sig;
- if (decode_der_dsa_sig(r, s, &pder, sizeof(t_dsa_sig)) == 0
+ if (ossl_decode_der_dsa_sig(r, s, &pder, sizeof(t_dsa_sig)) == 0
|| !TEST_ptr_eq(pder, (t_dsa_sig + sizeof(t_dsa_sig)))
|| !TEST_BN_eq_word(r, 1) || !TEST_BN_eq_word(s, 2)) {
TEST_info("asn1_dsa test_decode: t_dsa_sig failed");
BN_clear(r);
BN_clear(s);
pder = t_dsa_sig_extra;
- if (decode_der_dsa_sig(r, s, &pder, sizeof(t_dsa_sig_extra)) == 0
+ if (ossl_decode_der_dsa_sig(r, s, &pder, sizeof(t_dsa_sig_extra)) == 0
|| !TEST_ptr_eq(pder,
(t_dsa_sig_extra + sizeof(t_dsa_sig_extra) - 2))
|| !TEST_BN_eq_word(r, 1) || !TEST_BN_eq_word(s, 2)) {
BN_clear(r);
BN_clear(s);
pder = t_dsa_sig_msb;
- if (decode_der_dsa_sig(r, s, &pder, sizeof(t_dsa_sig_msb)) == 0
+ if (ossl_decode_der_dsa_sig(r, s, &pder, sizeof(t_dsa_sig_msb)) == 0
|| !TEST_ptr_eq(pder, (t_dsa_sig_msb + sizeof(t_dsa_sig_msb)))
|| !TEST_BN_eq_word(r, 0x81) || !TEST_BN_eq_word(s, 0x82)) {
TEST_info("asn1_dsa test_decode: t_dsa_sig_msb failed");
BN_clear(r);
BN_clear(s);
pder = t_dsa_sig_two;
- if (decode_der_dsa_sig(r, s, &pder, sizeof(t_dsa_sig_two)) == 0
+ if (ossl_decode_der_dsa_sig(r, s, &pder, sizeof(t_dsa_sig_two)) == 0
|| !TEST_ptr_eq(pder, (t_dsa_sig_two + sizeof(t_dsa_sig_two)))
|| !TEST_BN_eq_word(r, 0x100) || !TEST_BN_eq_word(s, 0x200)) {
TEST_info("asn1_dsa test_decode: t_dsa_sig_two failed");
/* Negative tests */
pder = t_invalid_int_zero;
- if (decode_der_dsa_sig(r, s, &pder, sizeof(t_invalid_int_zero)) != 0) {
+ if (ossl_decode_der_dsa_sig(r, s, &pder, sizeof(t_invalid_int_zero)) != 0) {
TEST_info("asn1_dsa test_decode: Expected t_invalid_int_zero to fail");
goto fail;
}
BN_clear(r);
BN_clear(s);
pder = t_invalid_int;
- if (decode_der_dsa_sig(r, s, &pder, sizeof(t_invalid_int)) != 0) {
+ if (ossl_decode_der_dsa_sig(r, s, &pder, sizeof(t_invalid_int)) != 0) {
TEST_info("asn1_dsa test_decode: Expected t_invalid_int to fail");
goto fail;
}
BN_clear(r);
BN_clear(s);
pder = t_neg_int;
- if (decode_der_dsa_sig(r, s, &pder, sizeof(t_neg_int)) != 0) {
+ if (ossl_decode_der_dsa_sig(r, s, &pder, sizeof(t_neg_int)) != 0) {
TEST_info("asn1_dsa test_decode: Expected t_neg_int to fail");
goto fail;
}
BN_clear(r);
BN_clear(s);
pder = t_trunc_der;
- if (decode_der_dsa_sig(r, s, &pder, sizeof(t_trunc_der)) != 0) {
+ if (ossl_decode_der_dsa_sig(r, s, &pder, sizeof(t_trunc_der)) != 0) {
TEST_info("asn1_dsa test_decode: Expected fail t_trunc_der");
goto fail;
}
BN_clear(r);
BN_clear(s);
pder = t_trunc_seq;
- if (decode_der_dsa_sig(r, s, &pder, sizeof(t_trunc_seq)) != 0) {
+ if (ossl_decode_der_dsa_sig(r, s, &pder, sizeof(t_trunc_seq)) != 0) {
TEST_info("asn1_dsa test_decode: Expected fail t_trunc_seq");
goto fail;
}