diff options
author | Florian Dold <florian@dold.me> | 2022-04-26 01:28:36 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-04-26 01:28:36 +0200 |
commit | 38fcca16c856c989cd0ed7b95e44ca0842a8a576 (patch) | |
tree | 4a7cbaff48e0267d7a63640b4d3d4d715197e8bf /src/util | |
parent | 505989a50754217b9fe8f627a279b2b00fb65262 (diff) |
fix age attestation signature padding and endianess
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/age_restriction.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/util/age_restriction.c b/src/util/age_restriction.c index dfb376b2d..f4a58946a 100644 --- a/src/util/age_restriction.c +++ b/src/util/age_restriction.c @@ -250,6 +250,16 @@ TALER_age_commitment_derive ( } +GNUNET_NETWORK_STRUCT_BEGIN + +/** + * Age group mask in network byte order. + */ +struct TALER_AgeMaskNBO +{ + uint32_t bits_nbo; +}; + /** * Used for attestation of a particular age */ @@ -263,14 +273,24 @@ struct TALER_AgeAttestationPS /** * Age mask that defines the underlying age groups */ - struct TALER_AgeMask mask; + struct TALER_AgeMaskNBO mask; /** * The particular age that this attestation is for */ uint8_t age; + + /** + * Pad to a total size of 16 bytes. + * + * (Strangly, the compiler leaves padding after the age + * field even with GNUNET_PACKED / GNUNET_NETWORK_STRUCT_BEGIN. + */ + uint8_t padding[3]; }; +GNUNET_NETWORK_STRUCT_END + enum GNUNET_GenericReturnValue TALER_age_commitment_attest ( @@ -305,8 +325,9 @@ TALER_age_commitment_attest ( struct TALER_AgeAttestationPS at = { .purpose.size = htonl (sizeof(at)), .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_AGE_ATTESTATION), - .mask = cp->commitment.mask, - .age = age + .mask.bits_nbo = GNUNET_htonll (cp->commitment.mask.bits), + .age = age, + .padding = { 0 }, }; #ifndef AGE_RESTRICTION_WITH_ECDSA @@ -344,14 +365,18 @@ TALER_age_commitment_verify ( return GNUNET_OK; if (group > comm->num) + { + GNUNET_break_op (0); return GNUNET_NO; + } { struct TALER_AgeAttestationPS at = { .purpose.size = htonl (sizeof(at)), .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_AGE_ATTESTATION), - .mask = comm->mask, + .mask.bits_nbo = GNUNET_htonll (comm->mask.bits), .age = age, + .padding = { 0 }, }; #ifndef AGE_RESTRICTION_WITH_ECDSA |