mirror of
https://github.com/polhenarejos/pico-openpgp.git
synced 2026-08-23 04:57:27 +01:00
Correct MSE template mapping
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
+10
-10
@@ -26,16 +26,6 @@ int cmd_mse(void) {
|
||||
return SW_WRONG_DATA();
|
||||
}
|
||||
if (P2(apdu) == 0xA4) {
|
||||
if (apdu.data[2] == 0x2) {
|
||||
algo_dec = EF_ALGO_PRIV2;
|
||||
pk_dec = EF_PK_DEC;
|
||||
}
|
||||
else if (apdu.data[2] == 0x3) {
|
||||
algo_dec = EF_ALGO_PRIV3;
|
||||
pk_dec = EF_PK_AUT;
|
||||
}
|
||||
}
|
||||
else if (P2(apdu) == 0xB8) {
|
||||
if (apdu.data[2] == 0x2) {
|
||||
algo_aut = EF_ALGO_PRIV2;
|
||||
pk_aut = EF_PK_DEC;
|
||||
@@ -45,5 +35,15 @@ int cmd_mse(void) {
|
||||
pk_aut = EF_PK_AUT;
|
||||
}
|
||||
}
|
||||
else if (P2(apdu) == 0xB8) {
|
||||
if (apdu.data[2] == 0x2) {
|
||||
algo_dec = EF_ALGO_PRIV2;
|
||||
pk_dec = EF_PK_DEC;
|
||||
}
|
||||
else if (apdu.data[2] == 0x3) {
|
||||
algo_dec = EF_ALGO_PRIV3;
|
||||
pk_dec = EF_PK_AUT;
|
||||
}
|
||||
}
|
||||
return SW_OK();
|
||||
}
|
||||
|
||||
@@ -463,7 +463,7 @@ def test_openpgp_mse_decipher_slot_swap(card):
|
||||
eph = ec.generate_private_key(ec.SECP256R1())
|
||||
peer = eph.public_key().public_bytes(serialization.Encoding.X962, serialization.PublicFormat.UncompressedPoint)
|
||||
z_dec = card.cmd_pso(0x80, 0x86, decipher_apdu_data(peer))
|
||||
expect(card, INS_MSE, 0x41, 0xA4, b"\x83\x01\x03")
|
||||
expect(card, INS_MSE, 0x41, 0xB8, b"\x83\x01\x03")
|
||||
z_aut = card.cmd_pso(0x80, 0x86, decipher_apdu_data(peer))
|
||||
assert z_dec == dec_priv.exchange(ec.ECDH(), eph.public_key())
|
||||
assert z_aut == aut_priv.exchange(ec.ECDH(), eph.public_key())
|
||||
|
||||
Reference in New Issue
Block a user