Skip to content

Commit

Permalink
test: update tests to use EC keys
Browse files Browse the repository at this point in the history
Migrate tests to EC keys.
Remove duplicated code.
  • Loading branch information
Salvatore Laiso committed Dec 18, 2023
1 parent b280092 commit 726dd90
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 378 deletions.
4 changes: 2 additions & 2 deletions example/satosa/integration_test/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from pyeudiw.jwt import DEFAULT_SIG_KTY_MAP
from pyeudiw.presentation_exchange.schemas.oid4vc_presentation_definition import PresentationDefinition
from pyeudiw.tests.federation.base_ec import (
from pyeudiw.tests.federation.base import (
EXP,
leaf_cred,
leaf_cred_jwk,
Expand Down Expand Up @@ -37,7 +37,7 @@
from saml2_sp import saml2_request, IDP_BASEURL
from sd_jwt.holder import SDJWTHolder

from settings_ec import (
from settings import (
CONFIG_DB,
RP_EID,
WALLET_INSTANCE_ATTESTATION,
Expand Down
6 changes: 3 additions & 3 deletions example/satosa/integration_test/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
]
}
rp_signer = JWS(
rp_ec, alg="RS256",
rp_ec, alg="ES256",
typ="application/entity-statement+jwt"
)

Expand All @@ -125,11 +125,11 @@
}
}
ta_signer = JWS(
_es, alg="RS256",
_es, alg="ES256",
typ="application/entity-statement+jwt"
)

its_trust_chain = [
rp_signer.sign_compact([key_from_jwk_dict(rp_jwks[0])]),
rp_signer.sign_compact([key_from_jwk_dict(rp_jwks[1])]),
ta_signer.sign_compact([ta_jwk])
]
135 changes: 0 additions & 135 deletions example/satosa/integration_test/settings_ec.py

This file was deleted.

29 changes: 16 additions & 13 deletions pyeudiw/tests/federation/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from cryptojwt.jwk.ec import new_ec_key
from cryptojwt.jws.jws import JWS
from cryptojwt.jwk.rsa import new_rsa_key

import json
import pyeudiw.federation.trust_chain_validator as tcv_test
Expand All @@ -13,15 +13,18 @@
NOW = iat_now()
EXP = exp_from_now(5000)

ec_crv = "P-256"
ec_alg = "ES256"

# Define intermediate ec
intermediate_jwk = new_rsa_key()
intermediate_jwk = new_ec_key(ec_crv, alg=ec_alg)

# Define TA ec
ta_jwk = new_rsa_key()
ta_jwk = new_ec_key(ec_crv, alg=ec_alg)

# Define leaf Credential Issuer
leaf_cred_jwk = new_rsa_key()
leaf_cred_jwk_prot = new_rsa_key()
leaf_cred_jwk = new_ec_key(ec_crv, alg=ec_alg)
leaf_cred_jwk_prot = new_ec_key(ec_crv, alg=ec_alg)
leaf_cred = {
"exp": EXP,
"iat": NOW,
Expand Down Expand Up @@ -62,7 +65,7 @@
intermediate_es_cred["jwks"]['keys'] = [leaf_cred_jwk.serialize()]

# Define leaf Wallet Provider
leaf_wallet_jwk = new_rsa_key()
leaf_wallet_jwk = new_ec_key(ec_crv, alg=ec_alg)
leaf_wallet = {
"exp": EXP,
"iat": NOW,
Expand Down Expand Up @@ -155,37 +158,37 @@
}

# Sign step
leaf_cred_signer = JWS(leaf_cred, alg='RS256',
leaf_cred_signer = JWS(leaf_cred, alg=ec_alg,
typ='entity-statement+jwt')
leaf_cred_signed = leaf_cred_signer.sign_compact([leaf_cred_jwk])

leaf_wallet_signer = JWS(leaf_wallet, alg='RS256',
leaf_wallet_signer = JWS(leaf_wallet, alg=ec_alg,
typ='entity-statement+jwt')
leaf_wallet_signed = leaf_wallet_signer.sign_compact([leaf_wallet_jwk])


intermediate_signer_ec = JWS(
intermediate_ec, alg="RS256",
intermediate_ec, alg=ec_alg,
typ="entity-statement+jwt"
)
intermediate_ec_signed = intermediate_signer_ec.sign_compact([
intermediate_jwk])


intermediate_signer_es_cred = JWS(
intermediate_es_cred, alg='RS256', typ='entity-statement+jwt')
intermediate_es_cred, alg=ec_alg, typ='entity-statement+jwt')
intermediate_es_cred_signed = intermediate_signer_es_cred.sign_compact([
intermediate_jwk])

intermediate_signer_es_wallet = JWS(
intermediate_es_wallet, alg='RS256', typ='entity-statement+jwt')
intermediate_es_wallet, alg=ec_alg, typ='entity-statement+jwt')
intermediate_es_wallet_signed = intermediate_signer_es_wallet.sign_compact([
intermediate_jwk])

ta_es_signer = JWS(ta_es, alg="RS256", typ="entity-statement+jwt")
ta_es_signer = JWS(ta_es, alg=ec_alg, typ="entity-statement+jwt")
ta_es_signed = ta_es_signer.sign_compact([ta_jwk])

ta_ec_signer = JWS(ta_ec, alg="RS256", typ="entity-statement+jwt")
ta_ec_signer = JWS(ta_ec, alg=ec_alg, typ="entity-statement+jwt")
ta_ec_signed = ta_ec_signer.sign_compact([ta_jwk])


Expand Down
Loading

0 comments on commit 726dd90

Please sign in to comment.