Current section

Files

Jump to
gossamer src gossamer subtle_crypto derive_algorithm.ffi.mjs
Raw

src/gossamer/subtle_crypto/derive_algorithm.ffi.mjs

// src/gossamer/subtle_crypto/derive_algorithm.ffi.ts
import * as $alg from "./derive_algorithm.mjs";
import { toHashAlgorithm } from "../hash_algorithm.ffi.mjs";
function toDeriveAlgorithm(algorithm) {
if ($alg.DeriveAlgorithm$isOther(algorithm)) {
return $alg.DeriveAlgorithm$Other$0(algorithm);
}
if ($alg.DeriveAlgorithm$isHkdf(algorithm)) {
return {
name: "HKDF",
hash: toHashAlgorithm($alg.DeriveAlgorithm$Hkdf$hash(algorithm)),
info: $alg.DeriveAlgorithm$Hkdf$info(
algorithm
),
salt: $alg.DeriveAlgorithm$Hkdf$salt(
algorithm
)
};
}
if ($alg.DeriveAlgorithm$isPbkdf2(algorithm)) {
return {
name: "PBKDF2",
hash: toHashAlgorithm($alg.DeriveAlgorithm$Pbkdf2$hash(algorithm)),
iterations: $alg.DeriveAlgorithm$Pbkdf2$iterations(algorithm),
salt: $alg.DeriveAlgorithm$Pbkdf2$salt(
algorithm
)
};
}
return {
name: "ECDH",
public: $alg.DeriveAlgorithm$Ecdh$public(algorithm)
};
}
export {
toDeriveAlgorithm
};