@@ -131,13 +131,35 @@ static int pqdsa_pub_encode(CBB *out, const EVP_PKEY *pkey) {
131131 return 1 ;
132132}
133133
134+ static int pqdsa_cmp_parameters (const EVP_PKEY * a , const EVP_PKEY * b ) {
135+ const PQDSA_KEY * a_key = a -> pkey .pqdsa_key ;
136+ const PQDSA_KEY * b_key = b -> pkey .pqdsa_key ;
137+ if (a_key == NULL || b_key == NULL ) {
138+ return -2 ;
139+ }
140+
141+ const PQDSA * a_pqdsa = a_key -> pqdsa ;
142+ const PQDSA * b_pqdsa = b_key -> pqdsa ;
143+ if (a_pqdsa == NULL || b_pqdsa == NULL ) {
144+ return -2 ;
145+ }
146+
147+ return a_pqdsa -> nid == b_pqdsa -> nid ;
148+ }
149+
134150static int pqdsa_pub_cmp (const EVP_PKEY * a , const EVP_PKEY * b ) {
135- PQDSA_KEY * a_key = a -> pkey .pqdsa_key ;
136- PQDSA_KEY * b_key = b -> pkey .pqdsa_key ;
151+ int ret = pqdsa_cmp_parameters (a , b );
152+ if (ret <= 0 ) {
153+ return ret ;
154+ }
137155
138- return OPENSSL_memcmp (a_key -> public_key ,
139- b_key -> public_key ,
140- a -> pkey .pqdsa_key -> pqdsa -> public_key_len ) == 0 ;
156+ const PQDSA_KEY * a_key = a -> pkey .pqdsa_key ;
157+ const PQDSA_KEY * b_key = b -> pkey .pqdsa_key ;
158+ if (a_key -> public_key == NULL || b_key -> public_key == NULL ) {
159+ return -2 ;
160+ }
161+ return OPENSSL_memcmp (a_key -> public_key , b_key -> public_key ,
162+ a_key -> pqdsa -> public_key_len ) == 0 ;
141163}
142164
143165static int pqdsa_priv_decode (EVP_PKEY * out , CBS * oid , CBS * params , CBS * key , CBS * pubkey ) {
0 commit comments