Skip to content

Commit

Permalink
Backport k3.seal fix from v2 branch
Browse files Browse the repository at this point in the history
See #12, #13
  • Loading branch information
paragonie-security committed Oct 11, 2022
1 parent 290aae8 commit 3cf1d9b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Operations/PKE/PKEv3.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function seal(SymmetricKey $ptk, SealingPublicKey $pk): string
$eph_pk = $eph_sk->getPublicKey();
$seal_pk = PublicKey::importPem($pk->raw());

$pk_compressed = $seal_pk->toString();
$pk_compressed = Hex::decode($seal_pk->toString());
$eph_pk_compressed = Hex::decode($eph_pk->toString());

// Step 2:
Expand Down Expand Up @@ -168,7 +168,7 @@ public function unseal(string $header, string $encoded, SealingSecretKey $sk): S
if (!($pk_obj instanceof PublicKey)) {
throw new TypeError("An unexpected type violation occurred");
}
$pk_compressed = $pk_obj->toString();
$pk_compressed = Hex::decode($pk_obj->toString());

// Step 2:
$Ak = hash(
Expand Down
4 changes: 2 additions & 2 deletions tests/test-vectors/k3.seal.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"sealing-secret-key": "-----BEGIN EC PRIVATE KEY-----\nMIGkAgEBBDAhUb6WGhABE1MTj0x7E/5acgyap23kh7hUAVoAavKyfhYcmI3n1Q7L\nJpHxNb792H6gBwYFK4EEACKhZANiAAT5H7mTSOyjfILDtSuavZfalI3doM8pRUlb\nTzNyYLqM9iVmajpc0JRXvKuBtGtYi7Yft+eqFr6BuzGrdb4Z1vkvRcI504m0qKiE\nzjhi6u4sNgzW23rrVkRYkb2oE3SJPko=\n-----END EC PRIVATE KEY-----",
"sealing-public-key": "-----BEGIN PUBLIC KEY-----\nMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE+R+5k0jso3yCw7Urmr2X2pSN3aDPKUVJ\nW08zcmC6jPYlZmo6XNCUV7yrgbRrWIu2H7fnqha+gbsxq3W+Gdb5L0XCOdOJtKio\nhM44YuruLDYM1tt661ZEWJG9qBN0iT5K\n-----END PUBLIC KEY-----",
"unsealed": "0000000000000000000000000000000000000000000000000000000000000000",
"paserk": "k3.seal.Re1_8c1NeFaVVuzysZyNUUlv6oZE2zhpv_Bqs25hexJ1cKr4dDtKKtp9oWNJZ6v-Ah1dx3k4zPqRdua4fzjq8bYP6FYDc4mCqH4KZhwgsEOM955uO6HT_Vfg_Od0qoXhgQ3lHi1H10vBfFa0PaeDXK2B_H3_YQZH8Z_1lOGnRwb2"
"paserk": "k3.seal.NsI9NFzAouTSs7V5mejAeyBLYcoeNlbb9eY8C2KnkPTsARsPLen9KfMFfgqeI50FAnuRCdcb4HmXPaY3i-ZdBXwfdqSiB_65lmIHosVOJ7chmqqscnBkA7vc3mEAXxM05hSytjBYFxwlUnfFE3Sq3YHUZrOELF7PM87K6FFOMqc6"
},
{
"name": "k3.seal-2",
"expect-fail": false,
"sealing-secret-key": "-----BEGIN EC PRIVATE KEY-----\nMIGkAgEBBDAhUb6WGhABE1MTj0x7E/5acgyap23kh7hUAVoAavKyfhYcmI3n1Q7L\nJpHxNb792H6gBwYFK4EEACKhZANiAAT5H7mTSOyjfILDtSuavZfalI3doM8pRUlb\nTzNyYLqM9iVmajpc0JRXvKuBtGtYi7Yft+eqFr6BuzGrdb4Z1vkvRcI504m0qKiE\nzjhi6u4sNgzW23rrVkRYkb2oE3SJPko=\n-----END EC PRIVATE KEY-----",
"sealing-public-key": "-----BEGIN PUBLIC KEY-----\nMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE+R+5k0jso3yCw7Urmr2X2pSN3aDPKUVJ\nW08zcmC6jPYlZmo6XNCUV7yrgbRrWIu2H7fnqha+gbsxq3W+Gdb5L0XCOdOJtKio\nhM44YuruLDYM1tt661ZEWJG9qBN0iT5K\n-----END PUBLIC KEY-----",
"unsealed": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"paserk": "k3.seal.LpevSc3v4VYqlUjEr3OD4LSMaYspcU-VlqI8rpywnFwVKqT1sMJQB_K3GwyszVueA8QJ3KmBUr4ravEb8DsazPuXcWbrnQF4CJmUQSgaTI4YyCb35n-xkx8CDA7ig-m-lhhYKkp_r3Ybcm-s9BKPlPW2VRr791ukbrCSRXFkQ8sR"
"paserk": "k3.seal.qCFR9x-TwGcUQgprulNtvJqy7ZOipwmHQMOXXaJKetgYFsDm1aP3P9ljbCcDFlj0AqWxxuxaIFi59cCHDAysYdL5gzsVUTz-boo5G4V49FGiJu4kGj5pov1RKijsvaN4XQVhui57jUKWMy1fnjC5E6DrYlII2WWBKVMSbsnXuPGI"
},
{
"name": "k3.seal-fail-1",
Expand Down

0 comments on commit 3cf1d9b

Please sign in to comment.