getKeyPairBySpki method
Passes the key pair identified by publicKeySpkiDer
for
usage with platformKeys.subtleCrypto
to callback
.
|publicKeySpkiDer|: A DER-encoded X.509 SubjectPublicKeyInfo, obtained
e.g. by calling WebCrypto's exportKey function with format="spki".
|parameters|: Provides signature and hash algorithm parameters, in
addition to those fixed by the key itself. The same parameters are
accepted as by WebCrypto's importKey
function, e.g. RsaHashedImportParams
for a RSASSA-PKCS1-v1_5
key. For RSASSA-PKCS1-v1_5 keys, we need to also pass a "hash" parameter
{ "hash": { "name": string } }
. The "hash" parameter
represents the name of the hashing algorithm to be used in the digest
operation before a sign. It is possible to pass "none" as the hash name,
in which case the sign function will apply PKCS#1 v1.5 padding and but
not hash the given data.
Currently, this method supports the "ECDSA" algorithm with
named-curve P-256 and "RSASSA-PKCS1-v1_5" algorithm with one of the
hashing algorithms "none", "SHA-1", "SHA-256", "SHA-384", and
"SHA-512".
Implementation
Future<GetKeyPairBySpkiResult> getKeyPairBySpki(
ByteBuffer publicKeySpkiDer,
Map parameters,
) {
var $completer = Completer<GetKeyPairBySpkiResult>();
$js.chrome.platformKeys.getKeyPairBySpki(
publicKeySpkiDer.toJS,
parameters.jsify()!,
(
JSAny publicKey,
JSAny? privateKey,
) {
if (checkRuntimeLastError($completer)) {
$completer.complete(GetKeyPairBySpkiResult(
publicKey: publicKey.toDartMap(),
privateKey: privateKey?.toDartMap(),
));
}
}.toJS,
);
return $completer.future;
}