Current section
Files
Jump to
Current section
Files
src/gossamer/subtle_crypto/key_pair_gen_algorithm.ffi.mjs
// src/gossamer/subtle_crypto/key_pair_gen_algorithm.ffi.ts
import * as $alg from "./key_pair_gen_algorithm.mjs";
import { toEcAlgorithm } from "../ec_algorithm.ffi.mjs";
import { toHashAlgorithm } from "../hash_algorithm.ffi.mjs";
import { toNamedCurve } from "../named_curve.ffi.mjs";
import { toRsaAlgorithm } from "../rsa_algorithm.ffi.mjs";
import { unwrap as unwrapTypedArray } from "../typed_array.ffi.mjs";
function toKeyPairGenAlgorithm(algorithm) {
if ($alg.KeyPairGenAlgorithm$isOther(algorithm)) {
return $alg.KeyPairGenAlgorithm$Other$0(algorithm);
}
if ($alg.KeyPairGenAlgorithm$isRsa(algorithm)) {
return {
name: toRsaAlgorithm($alg.KeyPairGenAlgorithm$Rsa$name(algorithm)),
modulusLength: $alg.KeyPairGenAlgorithm$Rsa$modulus_length(algorithm),
publicExponent: unwrapTypedArray(
$alg.KeyPairGenAlgorithm$Rsa$public_exponent(algorithm)
),
hash: toHashAlgorithm($alg.KeyPairGenAlgorithm$Rsa$hash(algorithm))
};
}
if ($alg.KeyPairGenAlgorithm$isEd25519(algorithm)) return "Ed25519";
if ($alg.KeyPairGenAlgorithm$isX25519(algorithm)) return "X25519";
return {
name: toEcAlgorithm($alg.KeyPairGenAlgorithm$Ec$name(algorithm)),
namedCurve: toNamedCurve(
$alg.KeyPairGenAlgorithm$Ec$named_curve(algorithm)
)
};
}
export {
toKeyPairGenAlgorithm
};