Compare commits
No commits in common. "bbb7fc99ec9b1958eba0a3b7d206acfaddefe21d" and "ec826aa906c1f32186372863880d1f6417c947da" have entirely different histories.
bbb7fc99ec
...
ec826aa906
@ -136,7 +136,7 @@ ASN1._stringify = function(asn1) {
|
||||
var ws = '';
|
||||
|
||||
function write(asn1) {
|
||||
console.log(ws, 'ch', Enc.numToHex(asn1.type), asn1.length);
|
||||
console.log(ws, 'ch', Buffer.from([asn1.type]).toString('hex'), asn1.length);
|
||||
if (!asn1.children) {
|
||||
return;
|
||||
}
|
||||
@ -176,7 +176,7 @@ ASN1.tpl = function (asn1) {
|
||||
if (!asn1.children) {
|
||||
if (0x05 !== asn1.type) {
|
||||
if (0x06 !== asn1.type) {
|
||||
val = asn1.value || new Uint8Array(0);
|
||||
val = Buffer.from(asn1.value || '');
|
||||
vars.push("// 0x" + Enc.numToHex(val.byteLength) + " (" + val.byteLength + " bytes)\nopts.tpl" + i + " = '"
|
||||
+ Enc.bufToHex(val) + "';");
|
||||
if (0x02 !== asn1.type && 0x03 !== asn1.type) {
|
||||
|
43
test.sh
43
test.sh
@ -1,14 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
# cause errors to hard-fail
|
||||
# (and diff non-0 exit status will cause failure)
|
||||
set -e
|
||||
|
||||
pemtojwk() {
|
||||
keyid=$1
|
||||
if [ -z "$keyid" ]; then
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Testing PEM-to-JWK PKCS#1"
|
||||
echo ""
|
||||
fi
|
||||
#
|
||||
node bin/rasha.js ./fixtures/privkey-rsa-2048.pkcs1.${keyid}pem \
|
||||
@ -18,14 +17,13 @@ pemtojwk() {
|
||||
node bin/rasha.js ./fixtures/pub-rsa-2048.pkcs1.${keyid}pem \
|
||||
> ./fixtures/pub-rsa-2048.jwk.1.json
|
||||
diff ./fixtures/pub-rsa-2048.jwk.${keyid}json ./fixtures/pub-rsa-2048.jwk.1.json
|
||||
if [ -z "$keyid" ]; then
|
||||
echo "Pass"
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "$keyid" ]; then
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Testing PEM-to-JWK PKCS#8"
|
||||
echo ""
|
||||
fi
|
||||
#
|
||||
node bin/rasha.js ./fixtures/privkey-rsa-2048.pkcs8.${keyid}pem \
|
||||
@ -35,16 +33,15 @@ pemtojwk() {
|
||||
node bin/rasha.js ./fixtures/pub-rsa-2048.spki.${keyid}pem \
|
||||
> ./fixtures/pub-rsa-2048.jwk.1.json
|
||||
diff ./fixtures/pub-rsa-2048.jwk.${keyid}json ./fixtures/pub-rsa-2048.jwk.1.json
|
||||
if [ -z "$keyid" ]; then
|
||||
echo "Pass"
|
||||
fi
|
||||
}
|
||||
|
||||
jwktopem() {
|
||||
keyid=$1
|
||||
if [ -z "$keyid" ]; then
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Testing JWK-to-PEM PKCS#1"
|
||||
echo ""
|
||||
fi
|
||||
#
|
||||
node bin/rasha.js ./fixtures/privkey-rsa-2048.jwk.${keyid}json pkcs1 \
|
||||
@ -54,13 +51,13 @@ jwktopem() {
|
||||
node bin/rasha.js ./fixtures/pub-rsa-2048.jwk.${keyid}json pkcs1 \
|
||||
> ./fixtures/pub-rsa-2048.pkcs1.1.pem
|
||||
diff ./fixtures/pub-rsa-2048.pkcs1.${keyid}pem ./fixtures/pub-rsa-2048.pkcs1.1.pem
|
||||
if [ -z "$keyid" ]; then
|
||||
echo "Pass"
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "$keyid" ]; then
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Testing JWK-to-PEM PKCS#8"
|
||||
echo ""
|
||||
fi
|
||||
#
|
||||
node bin/rasha.js ./fixtures/privkey-rsa-2048.jwk.${keyid}json pkcs8 \
|
||||
@ -70,13 +67,13 @@ jwktopem() {
|
||||
node bin/rasha.js ./fixtures/pub-rsa-2048.jwk.${keyid}json spki \
|
||||
> ./fixtures/pub-rsa-2048.spki.1.pem
|
||||
diff ./fixtures/pub-rsa-2048.spki.${keyid}pem ./fixtures/pub-rsa-2048.spki.1.pem
|
||||
if [ -z "$keyid" ]; then
|
||||
echo "Pass"
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "$keyid" ]; then
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Testing JWK-to-SSH"
|
||||
echo ""
|
||||
fi
|
||||
#
|
||||
node bin/rasha.js ./fixtures/privkey-rsa-2048.jwk.${keyid}json ssh > ./fixtures/pub-rsa-2048.ssh.1.pub
|
||||
@ -84,9 +81,6 @@ jwktopem() {
|
||||
#
|
||||
node bin/rasha.js ./fixtures/pub-rsa-2048.jwk.${keyid}json ssh > ./fixtures/pub-rsa-2048.ssh.1.pub
|
||||
diff ./fixtures/pub-rsa-2048.ssh.${keyid}pub ./fixtures/pub-rsa-2048.ssh.1.pub
|
||||
if [ -z "$keyid" ]; then
|
||||
echo "Pass"
|
||||
fi
|
||||
}
|
||||
|
||||
rndkey() {
|
||||
@ -123,7 +117,7 @@ jwktopem ""
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Re-running tests with random keys of varying sizes"
|
||||
echo "Testing different size random keys"
|
||||
echo ""
|
||||
rndkey 32 # minimum key size
|
||||
rndkey 64
|
||||
@ -133,14 +127,11 @@ rndkey 512
|
||||
rndkey 768
|
||||
rndkey 1024
|
||||
rndkey 2048 # first secure key size
|
||||
#rndkey 3072
|
||||
#rndkey 4096 # largest reasonable key size
|
||||
if [ -z "$keyid" ]; then
|
||||
echo "Pass"
|
||||
fi
|
||||
rndkey 3072
|
||||
rndkey 4096 # largest reasonable key size
|
||||
echo ""
|
||||
echo "Note:"
|
||||
echo "Keys larger than 2048 have been tested and work, but are omitted from automated tests to save time."
|
||||
echo "Keys larger than 4096 work as well, but they take minutes to generate, so we stop here."
|
||||
|
||||
|
||||
rm fixtures/*.1.*
|
||||
@ -150,4 +141,4 @@ echo ""
|
||||
echo "PASSED:"
|
||||
echo "• All inputs produced valid outputs"
|
||||
echo "• All outputs matched known-good values"
|
||||
echo "• All random tests passed reciprosity"
|
||||
echo ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user