Simple asymmetric encryption, C++ implementation
data encryption on the systems, where storing password or key in cleartext is not desirable option.
Tool will use standard io streams where possible, or files could be specified on command line
Generate private key:
oneway --genkey private.key
oneway --genkey >private.key
Extract public key component from private key:
oneway --publickey private.key public.key
oneway --publickey <private.key >public.key
Encrypt file using public key:
oneway --encrypt public.key plaintext.txt encrypted.ascr
oneway --encrypt public.key plaintext.txt >encrypted.ascr
oneway --encrypt public.key <plaintext.txt >encrypted.ascr
Decrypt file using private key:
oneway --decrypt private.key encrypted.ascr plaintext.txt
oneway --decrypt private.key encrypted.ascr >plaintext.txt
oneway --decrypt private.key <encrypted.ascr >plaintext.txt
Where it is necessary to allow 3rd party independently decrypt files without providing private key, it is possible to decrypt files in two stages: first, a symmetric key is extracted, then file gets decrypted using given symmetric key
Extract symmetric key:
oneway --dump-key private.key encrypted.ascr key.base64
oneway --dump-key private.key encrypted.ascr >key.base64
oneway --dump-key private.key <encrypted.ascr >key.base64
Decrypt file using symmetric key:
oneway --decrypt-with-symkey "key-in-base64-format" encrypted.ascr plaintext.txt
oneway --decrypt-with-symkey "key-in-base64-format" encrypted.ascr >plaintext.txt
oneway --decrypt-with-symkey "key-in-base64-format" <encrypted.ascr >plaintext.txt
Symmetric key from one file would not work on any other file.
Each file is encrypted using AES-CBC-256 with randomly generated key. AES key is encrypted using 4096 bit RSA and stored with the file.
4 bytes: signature "ASCR"
16 bytes: AES IV
512 bytes: RSA 4096-encrypted AES key
rest: encrypted file contents
Files in compatible format are produced by similar .NET utility located at: https://github.com/galets/AsymmetricCrypt
This utility is licensed under GPLv3. See
- Crypto++ (https://github.com/weidai11/cryptopp)
- Crypto++ PEM Pack (https://github.com/noloader/cryptopp-pem)