parseDerSPKI function
Parses a DER SubjectPublicKeyInfo into the uncompressed point
(0x04 || x || y), verifying the curve is secp256r1 (P-256).
Implementation
Uint8List parseDerSPKI(Uint8List der) {
if (der.length !=
_secp256r1SpkiHeader.length + PASSKEY_UNCOMPRESSED_PUBLIC_KEY_SIZE) {
throw ArgumentError('Invalid DER length');
}
for (var i = 0; i < _secp256r1SpkiHeader.length; i++) {
if (der[i] != _secp256r1SpkiHeader[i]) {
throw ArgumentError('Invalid SPKI header');
}
}
if (der[_secp256r1SpkiHeader.length] != 0x04) {
throw ArgumentError('Invalid point marker');
}
return Uint8List.sublistView(der, _secp256r1SpkiHeader.length);
}