Skip to content

Commit 6117d0c

Browse files
committed
Fix bug where uncompressing key removes prefix
This method is supposed to remove the prefix if the argument is false. However, it does so indiscriminately. As a result, it can sometimes give the public key have 63 bytes. This commit fixes it by checking to see if removing the prefix would result in the public key having 63 bytes.
1 parent 4d05d7b commit 6117d0c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/ATCryptography/p256/P256Encoding.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public struct P256Encoding {
8686
}
8787
} else {
8888
// Ensure the key is returned without the prefix.
89-
if uncompressedKey.first == 0x04 {
89+
if uncompressedKey.first == 0x04 && (uncompressedKey.count - 1) != 63 {
9090
uncompressedKey.removeFirst()
9191
}
9292
}

0 commit comments

Comments
 (0)