pod.epiccastle.bbssh.key-pair
Everything related to SSH public/private key pairs. Functions for generating, loading, saving, encrypting and decrypting keys. Also a function for signing arbitrary data with the private key.
decrypt
(decrypt key-pair passphrase)decrypt the private key with the passed in byte-array so that the private key is no longer stored encrypted. Can be followed up with setting a new passphrase to re-encrypt. Returns true if the decryption succeeded.
dispose
(dispose key-pair)zero out the memory holding the private key passphrase so subsequent attacks on stale memory are thwarted
generate
(generate agent key-type)(generate agent key-type key-size)Generate a public/private SSH key pair. key-type should be :dsa, :rsa, :ecdsa, :ed25519 or :ed448. key-size is the number of bits and defaults to 2048.
get-finger-print
(get-finger-print key-pair)return the key finger print as a string.
get-key-size
(get-key-size key-pair)returns the bit length of the key
get-public-key-blob
(get-public-key-blob key-pair)returns a byte-array of the raw public key data.
get-signature
(get-signature key-pair data)(get-signature key-pair data algorithm)Sign the passed in data with the private key, using algorithm if it is passed aswell
is-encrypted
(is-encrypted key-pair)returns true if the private key is encrypted with a passphrase
load
(load agent private-key-file)(load agent private-key-file public-key-file)Load the key pair from a file. Pass both private and public filenames in to load from those files. If public key filename is omitted, the private key filename with “.pub” appended is used
load-bytes
(load-bytes agent private-key-bytes public-key-bytes)Load the key pair from a byte array. Pass both private and public keys either as byte arrays or as strings. Half a keypair can be loaded to perform some operations. You may pass in nil for one of the key portions to only load the public or private portion.
set-passphrase
(set-passphrase key-pair passphrase)Set the passphrase on the private key to the string passphrase
write-private-key
(write-private-key key-pair filename)(write-private-key key-pair filename passphrase)write the private key to a file filename. Optionally pass in a byte array passphrase to be used as a passphrase.
write-public-key
(write-public-key key-pair filename comment)write the public key to file filename with the attached comment string.