more extensive testing
This commit is contained in:
parent
0f8ec4e512
commit
b5bf81927c
1 changed files with 126 additions and 52 deletions
116
test.sh
116
test.sh
|
@ -1,64 +1,138 @@
|
|||
#!/bin/bash
|
||||
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.pem > ./fixtures/privkey-rsa-2048.jwk.1.json
|
||||
diff ./fixtures/privkey-rsa-2048.jwk.json ./fixtures/privkey-rsa-2048.jwk.1.json
|
||||
node bin/rasha.js ./fixtures/privkey-rsa-2048.pkcs1.${keyid}pem \
|
||||
> ./fixtures/privkey-rsa-2048.jwk.1.json
|
||||
diff ./fixtures/privkey-rsa-2048.jwk.${keyid}json ./fixtures/privkey-rsa-2048.jwk.1.json
|
||||
#
|
||||
node bin/rasha.js ./fixtures/pub-rsa-2048.pkcs1.pem > ./fixtures/pub-rsa-2048.jwk.1.json
|
||||
diff ./fixtures/pub-rsa-2048.jwk.json ./fixtures/pub-rsa-2048.jwk.1.json
|
||||
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 ""
|
||||
echo ""
|
||||
echo "Testing PEM-to-JWK PKCS#8"
|
||||
echo ""
|
||||
fi
|
||||
#
|
||||
node bin/rasha.js ./fixtures/privkey-rsa-2048.pkcs8.pem > ./fixtures/privkey-rsa-2048.jwk.1.json
|
||||
diff ./fixtures/privkey-rsa-2048.jwk.json ./fixtures/privkey-rsa-2048.jwk.1.json
|
||||
node bin/rasha.js ./fixtures/privkey-rsa-2048.pkcs8.${keyid}pem \
|
||||
> ./fixtures/privkey-rsa-2048.jwk.1.json
|
||||
diff ./fixtures/privkey-rsa-2048.jwk.${keyid}json ./fixtures/privkey-rsa-2048.jwk.1.json
|
||||
#
|
||||
node bin/rasha.js ./fixtures/pub-rsa-2048.spki.pem > ./fixtures/pub-rsa-2048.jwk.1.json
|
||||
diff ./fixtures/pub-rsa-2048.jwk.json ./fixtures/pub-rsa-2048.jwk.1.json
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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.json pkcs1 > ./fixtures/privkey-rsa-2048.pkcs1.1.pem
|
||||
diff ./fixtures/privkey-rsa-2048.pkcs1.pem ./fixtures/privkey-rsa-2048.pkcs1.1.pem
|
||||
node bin/rasha.js ./fixtures/privkey-rsa-2048.jwk.${keyid}json pkcs1 \
|
||||
> ./fixtures/privkey-rsa-2048.pkcs1.1.pem
|
||||
diff ./fixtures/privkey-rsa-2048.pkcs1.${keyid}pem ./fixtures/privkey-rsa-2048.pkcs1.1.pem
|
||||
#
|
||||
node bin/rasha.js ./fixtures/pub-rsa-2048.jwk.json pkcs1 > ./fixtures/pub-rsa-2048.pkcs1.1.pem
|
||||
diff ./fixtures/pub-rsa-2048.pkcs1.pem ./fixtures/pub-rsa-2048.pkcs1.1.pem
|
||||
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 ""
|
||||
echo ""
|
||||
echo "Testing JWK-to-PEM PKCS#8"
|
||||
echo ""
|
||||
fi
|
||||
#
|
||||
node bin/rasha.js ./fixtures/privkey-rsa-2048.jwk.json pkcs8 > ./fixtures/privkey-rsa-2048.pkcs8.1.pem
|
||||
diff ./fixtures/privkey-rsa-2048.pkcs8.pem ./fixtures/privkey-rsa-2048.pkcs8.1.pem
|
||||
node bin/rasha.js ./fixtures/privkey-rsa-2048.jwk.${keyid}json pkcs8 \
|
||||
> ./fixtures/privkey-rsa-2048.pkcs8.1.pem
|
||||
diff ./fixtures/privkey-rsa-2048.pkcs8.${keyid}pem ./fixtures/privkey-rsa-2048.pkcs8.1.pem
|
||||
#
|
||||
node bin/rasha.js ./fixtures/pub-rsa-2048.jwk.json spki > ./fixtures/pub-rsa-2048.spki.1.pem
|
||||
diff ./fixtures/pub-rsa-2048.spki.pem ./fixtures/pub-rsa-2048.spki.1.pem
|
||||
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 ""
|
||||
echo ""
|
||||
echo "Testing JWK-to-SSH"
|
||||
echo ""
|
||||
fi
|
||||
#
|
||||
node bin/rasha.js ./fixtures/privkey-rsa-2048.jwk.json ssh > ./fixtures/pub-rsa-2048.ssh.1.pub
|
||||
diff ./fixtures/pub-rsa-2048.ssh.pub ./fixtures/pub-rsa-2048.ssh.1.pub
|
||||
node bin/rasha.js ./fixtures/privkey-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
|
||||
#
|
||||
node bin/rasha.js ./fixtures/pub-rsa-2048.jwk.json ssh > ./fixtures/pub-rsa-2048.ssh.1.pub
|
||||
diff ./fixtures/pub-rsa-2048.ssh.pub ./fixtures/pub-rsa-2048.ssh.1.pub
|
||||
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
|
||||
}
|
||||
|
||||
rndkey() {
|
||||
keyid="rnd.1."
|
||||
keysize=$1
|
||||
# Generate 2048-bit RSA Keypair
|
||||
openssl genrsa -out fixtures/privkey-rsa-2048.pkcs1.${keyid}pem $keysize
|
||||
# Convert PKCS1 (traditional) RSA Keypair to PKCS8 format
|
||||
openssl rsa -in fixtures/privkey-rsa-2048.pkcs1.${keyid}pem -pubout \
|
||||
-out fixtures/pub-rsa-2048.spki.${keyid}pem
|
||||
# Export Public-only RSA Key in PKCS1 (traditional) format
|
||||
openssl pkcs8 -topk8 -nocrypt -in fixtures/privkey-rsa-2048.pkcs1.${keyid}pem \
|
||||
-out fixtures/privkey-rsa-2048.pkcs8.${keyid}pem
|
||||
# Convert PKCS1 (traditional) RSA Public Key to SPKI/PKIX format
|
||||
openssl rsa -in fixtures/pub-rsa-2048.spki.${keyid}pem -pubin -RSAPublicKey_out \
|
||||
-out fixtures/pub-rsa-2048.pkcs1.${keyid}pem
|
||||
# Convert RSA public key to SSH format
|
||||
sshpub=$(ssh-keygen -f fixtures/pub-rsa-2048.spki.${keyid}pem -i -mPKCS8)
|
||||
echo "$sshpub rsa@localhost" > fixtures/pub-rsa-2048.ssh.${keyid}pub
|
||||
|
||||
|
||||
# to JWK
|
||||
node bin/rasha.js ./fixtures/privkey-rsa-2048.pkcs1.${keyid}pem \
|
||||
> ./fixtures/privkey-rsa-2048.jwk.${keyid}json
|
||||
node bin/rasha.js ./fixtures/pub-rsa-2048.pkcs1.${keyid}pem \
|
||||
> ./fixtures/pub-rsa-2048.jwk.${keyid}json
|
||||
|
||||
pemtojwk "$keyid"
|
||||
jwktopem "$keyid"
|
||||
}
|
||||
|
||||
pemtojwk ""
|
||||
jwktopem ""
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Testing different size random keys"
|
||||
echo ""
|
||||
rndkey 32 # minimum key size
|
||||
rndkey 64
|
||||
rndkey 128
|
||||
rndkey 256
|
||||
rndkey 512
|
||||
rndkey 768
|
||||
rndkey 1024
|
||||
rndkey 2048 # first secure key size
|
||||
rndkey 3072
|
||||
rndkey 4096 # largest reasonable key size
|
||||
echo ""
|
||||
echo "Note:"
|
||||
echo "Keys larger than 4096 work as well, but they take minutes to generate, so we stop here."
|
||||
|
||||
|
||||
rm fixtures/*.1.*
|
||||
|
||||
|
|
Loading…
Reference in a new issue