Browse Source

der: _ossl prefix DER functions

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13038)
master
Pauli 2 years ago
parent
commit
a55b00bdbc
33 changed files with 199 additions and 191 deletions
  1. +8
    -8
      crypto/asn1_dsa.c
  2. +14
    -13
      crypto/der_writer.c
  3. +1
    -1
      crypto/dsa/dsa_sign.c
  4. +1
    -1
      crypto/ec/ec_asn1.c
  5. +4
    -4
      doc/internal/man3/ossl_DER_w_begin_sequence.pod
  6. +16
    -16
      doc/internal/man3/ossl_DER_w_bn.pod
  7. +7
    -7
      doc/internal/man3/ossl_DER_w_precompiled.pod
  8. +21
    -20
      doc/internal/man7/DERlib.pod
  9. +4
    -4
      include/crypto/asn1_dsa.h
  10. +12
    -11
      include/internal/der.h
  11. +3
    -3
      providers/common/der/der_dsa.h.in
  12. +5
    -4
      providers/common/der/der_dsa_key.c
  13. +5
    -5
      providers/common/der/der_dsa_sig.c
  14. +3
    -3
      providers/common/der/der_ec.h.in
  15. +5
    -5
      providers/common/der/der_ec_key.c
  16. +5
    -5
      providers/common/der/der_ec_sig.c
  17. +4
    -4
      providers/common/der/der_ecx.h.in
  18. +20
    -20
      providers/common/der/der_ecx_key.c
  19. +5
    -5
      providers/common/der/der_rsa.h.in
  20. +13
    -12
      providers/common/der/der_rsa_key.c
  21. +5
    -5
      providers/common/der/der_rsa_sig.c
  22. +4
    -4
      providers/common/der/der_sm2_key.c
  23. +3
    -3
      providers/common/der/der_sm2_sig.c
  24. +1
    -1
      providers/implementations/encode_decode/encode_key2any.c
  25. +8
    -8
      providers/implementations/kdfs/x942kdf.c
  26. +2
    -2
      providers/implementations/signature/dsa.c
  27. +2
    -1
      providers/implementations/signature/ecdsa.c
  28. +2
    -2
      providers/implementations/signature/eddsa.c
  29. +3
    -2
      providers/implementations/signature/rsa.c
  30. +2
    -1
      providers/implementations/storemgmt/file_store.c
  31. +1
    -1
      providers/implementations/storemgmt/file_store_der2obj.c
  32. +1
    -1
      providers/implementations/storemgmt/file_store_local.h
  33. +9
    -9
      test/asn1_dsa_internal_test.c

+ 8
- 8
crypto/asn1_dsa.c View File

@ -152,7 +152,7 @@ int encode_der_dsa_sig(WPACKET *pkt, const BIGNUM *r, const BIGNUM *s)
*
* 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;
@ -184,7 +184,7 @@ int decode_der_length(PACKET *pkt, PACKET *subpkt)
* 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;
@ -192,7 +192,7 @@ int decode_der_integer(PACKET *pkt, BIGNUM *n)
/* 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 */
@ -230,8 +230,8 @@ int decode_der_integer(PACKET *pkt, BIGNUM *n)
* 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;
@ -240,9 +240,9 @@ size_t decode_der_dsa_sig(BIGNUM *r, BIGNUM *s, const unsigned char **ppin,
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;


+ 14
- 13
crypto/der_writer.c View File

@ -48,15 +48,16 @@ static int int_end_context(WPACKET *pkt, int tag)
&& (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)
@ -66,8 +67,8 @@ 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)
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)
@ -77,7 +78,7 @@ int DER_w_octet_string(WPACKET *pkt, int tag,
&& 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);
@ -86,7 +87,7 @@ int DER_w_octet_string_uint32(WPACKET *pkt, int tag, uint32_t value)
*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,
@ -124,7 +125,7 @@ static int int_put_bytes_ulong(WPACKET *pkt, const void *v,
}
/* 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);
}
@ -147,17 +148,17 @@ static int int_put_bytes_bn(WPACKET *pkt, const void *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)
@ -167,13 +168,13 @@ int DER_w_null(WPACKET *pkt, int tag)
}
/* 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


+ 1
- 1
crypto/dsa/dsa_sign.c View File

@ -65,7 +65,7 @@ DSA_SIG *d2i_DSA_SIG(DSA_SIG **psig, const unsigned char **ppin, long len)
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;


+ 1
- 1
crypto/ec/ec_asn1.c View File

@ -1218,7 +1218,7 @@ ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **psig, const unsigned char **ppin, long len)
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;


doc/internal/man3/DER_w_begin_sequence.pod → doc/internal/man3/ossl_DER_w_begin_sequence.pod View File


doc/internal/man3/DER_w_bn.pod → doc/internal/man3/ossl_DER_w_bn.pod View File


doc/internal/man3/DER_w_precompiled.pod → doc/internal/man3/ossl_DER_w_precompiled.pod View File


+ 21
- 20
doc/internal/man7/DERlib.pod View File

@ -50,10 +50,10 @@ which is defined like this in ASN.1 terms:
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:
@ -61,7 +61,7 @@ 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
@ -116,25 +116,26 @@ value:
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


+ 4
- 4
include/crypto/asn1_dsa.h View File

@ -15,9 +15,9 @@
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

+ 12
- 11
include/internal/der.h View File

@ -69,19 +69,20 @@
/* 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);

+ 3
- 3
providers/common/der/der_dsa.h.in View File

@ -17,7 +17,7 @@
-}
/* 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);

+ 5
- 4
providers/common/der/der_dsa_key.c View File

@ -11,10 +11,11 @@
#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);
}

+ 5
- 5
providers/common/der/der_dsa_sig.c View File

@ -17,8 +17,8 @@
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;
@ -37,8 +37,8 @@ int DER_w_algorithmIdentifier_DSA_with_MD(WPACKET *pkt, int tag,
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);
}

+ 3
- 3
providers/common/der/der_ec.h.in View File

@ -17,7 +17,7 @@
-}
/* 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);

+ 5
- 5
providers/common/der/der_ec_key.c View File

@ -11,11 +11,11 @@
#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);
}

+ 5
- 5
providers/common/der/der_ec_sig.c View File

@ -24,8 +24,8 @@
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;
@ -44,8 +44,8 @@ int DER_w_algorithmIdentifier_ECDSA_with_MD(WPACKET *pkt, int 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);
}

+ 4
- 4
providers/common/der/der_ecx.h.in View File

@ -17,7 +17,7 @@
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);

+ 20
- 20
providers/common/der/der_ecx_key.c View File

@ -11,38 +11,38 @@
#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);
}

+ 5
- 5
providers/common/der/der_rsa.h.in View File

@ -19,10 +19,10 @@
-}
/* 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);

+ 13
- 12
providers/common/der/der_rsa_key.c View File

@ -264,7 +264,7 @@ static int DER_w_MaskGenAlgorithm(WPACKET *pkt, int tag,
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;
}
@ -275,7 +275,8 @@ static int DER_w_MaskGenAlgorithm(WPACKET *pkt, int tag,
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;
@ -329,14 +330,14 @@ int DER_w_RSASSA_PSS_params(WPACKET *pkt, int tag, const RSA_PSS_PARAMS_30 *pss)
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 */
@ -348,7 +349,7 @@ int DER_w_RSASSA_PSS_params(WPACKET *pkt, int tag, const RSA_PSS_PARAMS_30 *pss)
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;
@ -365,10 +366,10 @@ int DER_w_algorithmIdentifier_RSA(WPACKET *pkt, int tag, RSA *rsa)
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);
}

+ 5
- 5
providers/common/der/der_rsa_sig.c View File

@ -28,8 +28,8 @@
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;
@ -57,8 +57,8 @@ int DER_w_algorithmIdentifier_MDWithRSAEncryption(WPACKET *pkt, int tag,
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);
}

+ 4
- 4
providers/common/der/der_sm2_key.c View File

@ -14,10 +14,10 @@
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);
}

+ 3
- 3
providers/common/der/der_sm2_sig.c View File

@ -32,8 +32,8 @@ int DER_w_algorithmIdentifier_SM2_with_MD(WPACKET *pkt, int 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);
}

+ 1
- 1
providers/implementations/encode_decode/encode_key2any.c View File

@ -657,7 +657,7 @@ static int prepare_rsa_params(const void *rsa, int nid,
}
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;


+ 8
- 8
providers/implementations/kdfs/x942kdf.c View File

@ -94,14 +94,14 @@ static int DER_w_keyinfo(WPACKET *pkt,
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,
@ -111,11 +111,11 @@ 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);
}


+ 2
- 2
providers/implementations/signature/dsa.c View File

@ -157,8 +157,8 @@ static int dsa_setup_md(PROV_DSA_CTX *ctx,
*/
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);


+ 2
- 1
providers/implementations/signature/ecdsa.c View File

@ -233,7 +233,8 @@ static int ecdsa_digest_signverify_init(void *vctx, const char *mdname,
*/
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);


+ 2
- 2
providers/implementations/signature/eddsa.c View File

@ -94,10 +94,10 @@ static int eddsa_digest_signverify_init(void *vpeddsactx, const char *mdname,
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 */


+ 3
- 2
providers/implementations/signature/rsa.c View File

@ -221,8 +221,9 @@ static int rsa_setup_md(PROV_RSA_CTX *ctx, const char *mdname,
*/
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);


+ 2
- 1
providers/implementations/storemgmt/file_store.c View File

@ -557,7 +557,8 @@ static int file_setup_decoders(struct file_ctx_st *ctx)
* 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);


+ 1
- 1
providers/implementations/storemgmt/file_store_der2obj.c View File

@ -130,5 +130,5 @@ static const OSSL_DISPATCH der_to_obj_decoder_functions[] = {
{ 0, NULL }
};
const OSSL_ALGORITHM der_to_obj_algorithm =
const OSSL_ALGORITHM ossl_der_to_obj_algorithm =
{ "obj", NULL, der_to_obj_decoder_functions };

+ 1
- 1
providers/implementations/storemgmt/file_store_local.h View File

@ -7,5 +7,5 @@
* https://www.openssl.org/source/license.html
*/
extern const OSSL_ALGORITHM der_to_obj_algorithm;
extern const OSSL_ALGORITHM ossl_der_to_obj_algorithm;

+ 9
- 9
test/asn1_dsa_internal_test.c View File

@ -93,7 +93,7 @@ static int test_decode(void)
/* 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");
@ -103,7 +103,7 @@ static int test_decode(void)
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)) {
@ -114,7 +114,7 @@ static int test_decode(void)
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");
@ -124,7 +124,7 @@ static int test_decode(void)
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");
@ -133,7 +133,7 @@ static int test_decode(void)
/* 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;
}
@ -141,7 +141,7 @@ static int test_decode(void)
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;
}
@ -149,7 +149,7 @@ static int test_decode(void)
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;
}
@ -157,7 +157,7 @@ static int test_decode(void)
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;
}
@ -165,7 +165,7 @@ static int test_decode(void)
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;
}


Loading…
Cancel
Save