blob: d403f39aa4e48546f9341a0b175eb4239e91990b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
function pem_to_der(pem, type) {
const pemJoined = pem.toString().split('\n').join('');
const pemHeader = `-----BEGIN ${type} KEY-----`;
const pemFooter = `-----END ${type} KEY-----`;
const pemContents = pemJoined.substring(pemHeader.length, pemJoined.length - pemFooter.length);
return Buffer.from(pemContents, 'base64');
}
function base64decode(b64) {
const joined = b64.toString().split('\n').join('');
return Buffer.from(joined, 'base64');
}
function load_jwk(data) {
if (typeof data == 'string') {
let json = fs.readFileSync(`test/webcrypto/${data}`);
return JSON.parse(json);
}
return data;
}
|