Skip to content

Commit

Permalink
Add key type specific en- decoder
Browse files Browse the repository at this point in the history
Signed-off-by: Wolfgang Beck <[email protected]>
  • Loading branch information
wbeck10p committed Dec 18, 2024
1 parent f7228d2 commit 92c5639
Show file tree
Hide file tree
Showing 6 changed files with 596 additions and 52 deletions.
73 changes: 73 additions & 0 deletions oqsprov/oqs_decode_der2key.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) [2024,] 2024, Oracle and/or its affiliates. All rights reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
Expand Down Expand Up @@ -678,149 +679,221 @@ MAKE_DECODER(_ecp, "p521_hqc256", p521_hqc256, oqsx, PrivateKeyInfo);
MAKE_DECODER(_ecp, "p521_hqc256", p521_hqc256, oqsx, SubjectPublicKeyInfo);
#endif /* OQS_KEM_ENCODERS */

MAKE_DECODER(, "dilithium2", dilithium2, oqsx, type_specific_keypair);
MAKE_DECODER(, "dilithium2", dilithium2, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "dilithium2", dilithium2, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "p256_dilithium2", p256_dilithium2, oqsx, type_specific_keypair);
MAKE_DECODER(, "p256_dilithium2", p256_dilithium2, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "p256_dilithium2", p256_dilithium2, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "rsa3072_dilithium2", rsa3072_dilithium2, oqsx, type_specific_keypair);
MAKE_DECODER(, "rsa3072_dilithium2", rsa3072_dilithium2, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "rsa3072_dilithium2", rsa3072_dilithium2, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "dilithium3", dilithium3, oqsx, type_specific_keypair);
MAKE_DECODER(, "dilithium3", dilithium3, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "dilithium3", dilithium3, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "p384_dilithium3", p384_dilithium3, oqsx, type_specific_keypair);
MAKE_DECODER(, "p384_dilithium3", p384_dilithium3, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "p384_dilithium3", p384_dilithium3, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "dilithium5", dilithium5, oqsx, type_specific_keypair);
MAKE_DECODER(, "dilithium5", dilithium5, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "dilithium5", dilithium5, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "p521_dilithium5", p521_dilithium5, oqsx, type_specific_keypair);
MAKE_DECODER(, "p521_dilithium5", p521_dilithium5, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "p521_dilithium5", p521_dilithium5, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mldsa44", mldsa44, oqsx, type_specific_keypair);
MAKE_DECODER(, "mldsa44", mldsa44, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mldsa44", mldsa44, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "p256_mldsa44", p256_mldsa44, oqsx, type_specific_keypair);
MAKE_DECODER(, "p256_mldsa44", p256_mldsa44, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "p256_mldsa44", p256_mldsa44, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "rsa3072_mldsa44", rsa3072_mldsa44, oqsx, type_specific_keypair);
MAKE_DECODER(, "rsa3072_mldsa44", rsa3072_mldsa44, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "rsa3072_mldsa44", rsa3072_mldsa44, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mldsa44_pss2048", mldsa44_pss2048, oqsx, type_specific_keypair);
MAKE_DECODER(, "mldsa44_pss2048", mldsa44_pss2048, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mldsa44_pss2048", mldsa44_pss2048, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mldsa44_rsa2048", mldsa44_rsa2048, oqsx, type_specific_keypair);
MAKE_DECODER(, "mldsa44_rsa2048", mldsa44_rsa2048, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mldsa44_rsa2048", mldsa44_rsa2048, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mldsa44_ed25519", mldsa44_ed25519, oqsx, type_specific_keypair);
MAKE_DECODER(, "mldsa44_ed25519", mldsa44_ed25519, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mldsa44_ed25519", mldsa44_ed25519, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mldsa44_p256", mldsa44_p256, oqsx, type_specific_keypair);
MAKE_DECODER(, "mldsa44_p256", mldsa44_p256, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mldsa44_p256", mldsa44_p256, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mldsa44_bp256", mldsa44_bp256, oqsx, type_specific_keypair);
MAKE_DECODER(, "mldsa44_bp256", mldsa44_bp256, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mldsa44_bp256", mldsa44_bp256, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mldsa65", mldsa65, oqsx, type_specific_keypair);
MAKE_DECODER(, "mldsa65", mldsa65, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mldsa65", mldsa65, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "p384_mldsa65", p384_mldsa65, oqsx, type_specific_keypair);
MAKE_DECODER(, "p384_mldsa65", p384_mldsa65, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "p384_mldsa65", p384_mldsa65, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mldsa65_pss3072", mldsa65_pss3072, oqsx, type_specific_keypair);
MAKE_DECODER(, "mldsa65_pss3072", mldsa65_pss3072, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mldsa65_pss3072", mldsa65_pss3072, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mldsa65_rsa3072", mldsa65_rsa3072, oqsx, type_specific_keypair);
MAKE_DECODER(, "mldsa65_rsa3072", mldsa65_rsa3072, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mldsa65_rsa3072", mldsa65_rsa3072, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mldsa65_p256", mldsa65_p256, oqsx, type_specific_keypair);
MAKE_DECODER(, "mldsa65_p256", mldsa65_p256, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mldsa65_p256", mldsa65_p256, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mldsa65_bp256", mldsa65_bp256, oqsx, type_specific_keypair);
MAKE_DECODER(, "mldsa65_bp256", mldsa65_bp256, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mldsa65_bp256", mldsa65_bp256, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mldsa65_ed25519", mldsa65_ed25519, oqsx, type_specific_keypair);
MAKE_DECODER(, "mldsa65_ed25519", mldsa65_ed25519, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mldsa65_ed25519", mldsa65_ed25519, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mldsa87", mldsa87, oqsx, type_specific_keypair);
MAKE_DECODER(, "mldsa87", mldsa87, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mldsa87", mldsa87, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "p521_mldsa87", p521_mldsa87, oqsx, type_specific_keypair);
MAKE_DECODER(, "p521_mldsa87", p521_mldsa87, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "p521_mldsa87", p521_mldsa87, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mldsa87_p384", mldsa87_p384, oqsx, type_specific_keypair);
MAKE_DECODER(, "mldsa87_p384", mldsa87_p384, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mldsa87_p384", mldsa87_p384, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mldsa87_bp384", mldsa87_bp384, oqsx, type_specific_keypair);
MAKE_DECODER(, "mldsa87_bp384", mldsa87_bp384, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mldsa87_bp384", mldsa87_bp384, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mldsa87_ed448", mldsa87_ed448, oqsx, type_specific_keypair);
MAKE_DECODER(, "mldsa87_ed448", mldsa87_ed448, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mldsa87_ed448", mldsa87_ed448, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "falcon512", falcon512, oqsx, type_specific_keypair);
MAKE_DECODER(, "falcon512", falcon512, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "falcon512", falcon512, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "p256_falcon512", p256_falcon512, oqsx, type_specific_keypair);
MAKE_DECODER(, "p256_falcon512", p256_falcon512, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "p256_falcon512", p256_falcon512, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "rsa3072_falcon512", rsa3072_falcon512, oqsx, type_specific_keypair);
MAKE_DECODER(, "rsa3072_falcon512", rsa3072_falcon512, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "rsa3072_falcon512", rsa3072_falcon512, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "falconpadded512", falconpadded512, oqsx, type_specific_keypair);
MAKE_DECODER(, "falconpadded512", falconpadded512, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "falconpadded512", falconpadded512, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "p256_falconpadded512", p256_falconpadded512, oqsx,
type_specific_keypair);
MAKE_DECODER(, "p256_falconpadded512", p256_falconpadded512, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "p256_falconpadded512", p256_falconpadded512, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "rsa3072_falconpadded512", rsa3072_falconpadded512, oqsx,
type_specific_keypair);
MAKE_DECODER(, "rsa3072_falconpadded512", rsa3072_falconpadded512, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "rsa3072_falconpadded512", rsa3072_falconpadded512, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "falcon1024", falcon1024, oqsx, type_specific_keypair);
MAKE_DECODER(, "falcon1024", falcon1024, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "falcon1024", falcon1024, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "p521_falcon1024", p521_falcon1024, oqsx, type_specific_keypair);
MAKE_DECODER(, "p521_falcon1024", p521_falcon1024, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "p521_falcon1024", p521_falcon1024, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "falconpadded1024", falconpadded1024, oqsx, type_specific_keypair);
MAKE_DECODER(, "falconpadded1024", falconpadded1024, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "falconpadded1024", falconpadded1024, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "p521_falconpadded1024", p521_falconpadded1024, oqsx,
type_specific_keypair);
MAKE_DECODER(, "p521_falconpadded1024", p521_falconpadded1024, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "p521_falconpadded1024", p521_falconpadded1024, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "sphincssha2128fsimple", sphincssha2128fsimple, oqsx,
type_specific_keypair);
MAKE_DECODER(, "sphincssha2128fsimple", sphincssha2128fsimple, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "sphincssha2128fsimple", sphincssha2128fsimple, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "p256_sphincssha2128fsimple", p256_sphincssha2128fsimple, oqsx,
type_specific_keypair);
MAKE_DECODER(, "p256_sphincssha2128fsimple", p256_sphincssha2128fsimple, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "p256_sphincssha2128fsimple", p256_sphincssha2128fsimple, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "rsa3072_sphincssha2128fsimple", rsa3072_sphincssha2128fsimple,
oqsx, type_specific_keypair);
MAKE_DECODER(, "rsa3072_sphincssha2128fsimple", rsa3072_sphincssha2128fsimple,
oqsx, PrivateKeyInfo);
MAKE_DECODER(, "rsa3072_sphincssha2128fsimple", rsa3072_sphincssha2128fsimple,
oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "sphincssha2128ssimple", sphincssha2128ssimple, oqsx,
type_specific_keypair);
MAKE_DECODER(, "sphincssha2128ssimple", sphincssha2128ssimple, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "sphincssha2128ssimple", sphincssha2128ssimple, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "p256_sphincssha2128ssimple", p256_sphincssha2128ssimple, oqsx,
type_specific_keypair);
MAKE_DECODER(, "p256_sphincssha2128ssimple", p256_sphincssha2128ssimple, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "p256_sphincssha2128ssimple", p256_sphincssha2128ssimple, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "rsa3072_sphincssha2128ssimple", rsa3072_sphincssha2128ssimple,
oqsx, type_specific_keypair);
MAKE_DECODER(, "rsa3072_sphincssha2128ssimple", rsa3072_sphincssha2128ssimple,
oqsx, PrivateKeyInfo);
MAKE_DECODER(, "rsa3072_sphincssha2128ssimple", rsa3072_sphincssha2128ssimple,
oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "sphincssha2192fsimple", sphincssha2192fsimple, oqsx,
type_specific_keypair);
MAKE_DECODER(, "sphincssha2192fsimple", sphincssha2192fsimple, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "sphincssha2192fsimple", sphincssha2192fsimple, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "p384_sphincssha2192fsimple", p384_sphincssha2192fsimple, oqsx,
type_specific_keypair);
MAKE_DECODER(, "p384_sphincssha2192fsimple", p384_sphincssha2192fsimple, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "p384_sphincssha2192fsimple", p384_sphincssha2192fsimple, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "sphincsshake128fsimple", sphincsshake128fsimple, oqsx,
type_specific_keypair);
MAKE_DECODER(, "sphincsshake128fsimple", sphincsshake128fsimple, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "sphincsshake128fsimple", sphincsshake128fsimple, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "p256_sphincsshake128fsimple", p256_sphincsshake128fsimple, oqsx,
type_specific_keypair);
MAKE_DECODER(, "p256_sphincsshake128fsimple", p256_sphincsshake128fsimple, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "p256_sphincsshake128fsimple", p256_sphincsshake128fsimple, oqsx,
SubjectPublicKeyInfo);
MAKE_DECODER(, "rsa3072_sphincsshake128fsimple", rsa3072_sphincsshake128fsimple,
oqsx, type_specific_keypair);
MAKE_DECODER(, "rsa3072_sphincsshake128fsimple", rsa3072_sphincsshake128fsimple,
oqsx, PrivateKeyInfo);
MAKE_DECODER(, "rsa3072_sphincsshake128fsimple", rsa3072_sphincsshake128fsimple,
oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mayo1", mayo1, oqsx, type_specific_keypair);
MAKE_DECODER(, "mayo1", mayo1, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mayo1", mayo1, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "p256_mayo1", p256_mayo1, oqsx, type_specific_keypair);
MAKE_DECODER(, "p256_mayo1", p256_mayo1, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "p256_mayo1", p256_mayo1, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mayo2", mayo2, oqsx, type_specific_keypair);
MAKE_DECODER(, "mayo2", mayo2, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mayo2", mayo2, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "p256_mayo2", p256_mayo2, oqsx, type_specific_keypair);
MAKE_DECODER(, "p256_mayo2", p256_mayo2, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "p256_mayo2", p256_mayo2, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mayo3", mayo3, oqsx, type_specific_keypair);
MAKE_DECODER(, "mayo3", mayo3, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mayo3", mayo3, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "p384_mayo3", p384_mayo3, oqsx, type_specific_keypair);
MAKE_DECODER(, "p384_mayo3", p384_mayo3, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "p384_mayo3", p384_mayo3, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "mayo5", mayo5, oqsx, type_specific_keypair);
MAKE_DECODER(, "mayo5", mayo5, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "mayo5", mayo5, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "p521_mayo5", p521_mayo5, oqsx, type_specific_keypair);
MAKE_DECODER(, "p521_mayo5", p521_mayo5, oqsx, PrivateKeyInfo);
MAKE_DECODER(, "p521_mayo5", p521_mayo5, oqsx, SubjectPublicKeyInfo);
MAKE_DECODER(, "CROSSrsdp128balanced", CROSSrsdp128balanced, oqsx,
type_specific_keypair);
MAKE_DECODER(, "CROSSrsdp128balanced", CROSSrsdp128balanced, oqsx,
PrivateKeyInfo);
MAKE_DECODER(, "CROSSrsdp128balanced", CROSSrsdp128balanced, oqsx,
Expand Down
Loading

0 comments on commit 92c5639

Please sign in to comment.