Liking cljdoc? Tell your friends :D

org.rssys.gost.encrypt

Encryption / decryption functions using GOST

Encryption / decryption functions using GOST
raw docstring

*password-unique-symbols-min-count*clj

How many unique symbols in password should be

How many unique symbols in password should be
sourceraw docstring

*secret-key-unique-bytes-min-count*clj

How many unique bytes in secret key should be

How many unique bytes in secret key should be
sourceraw docstring

algo-nameclj

(algo-name cp)

Get algorithm name for given crypto primitive. Returns String name.

Get algorithm name for given crypto primitive. Returns String name.
sourceraw docstring

allowed-algo-names-setclj

GOST symmetric algorithms

GOST symmetric algorithms
sourceraw docstring

allowed-cipher-modes-mapclj

source

allowed-cipher-modes-setclj

source

byte-array->secret-keyclj

(byte-array->secret-key sk-bytes)
(byte-array->secret-key sk-bytes algo-name)

Create secret key from the byte array. Returns ^SecretKeySpec. This function prevents the loading of weak keys. Params:

  • sk-bytes - byte array 32 bytes length
  • algo - allowed values "GOST28147" or "GOST3412-2015" (default)
Create secret key from the byte array.
Returns ^SecretKeySpec.
This function prevents the loading of weak keys.
Params:
  * `sk-bytes` - byte array 32 bytes length
  * `algo` - allowed values "GOST28147" or "GOST3412-2015" (default)
sourceraw docstring

compress-and-encrypt-streamclj

(compress-and-encrypt-stream cipher
                             input
                             output
                             &
                             {:keys [close-streams?] :or {close-streams? true}})

Compress and then encrypt given streaming input and write encrypted data to streaming output, using given initialized ^Cipher in encryption mode. As input may be: File, URI, URL, Socket, byte array, or filename as String which will be coerced to BufferedInputStream and auto closed after. Output should be File, URI, URL, Socket, or filename as String which will be coerced to BufferedOutputStream and auto closed after.

Compress and then encrypt given streaming input and write encrypted data to streaming output,
using given initialized ^Cipher in encryption mode.
As input may be: File, URI, URL, Socket, byte array, or filename as String which will be
coerced to BufferedInputStream and auto closed after.
Output should be  File, URI, URL, Socket, or filename as String  which  will be
coerced to BufferedOutputStream and auto closed after.
sourceraw docstring

compress-bytesclj

(compress-bytes plain-bytes)

Compress plain bytes array using Deflate Zip. Returns: byte array of compressed data.

Compress plain bytes array using Deflate Zip.
Returns: byte array of compressed data.
sourceraw docstring

compress-streamclj

(compress-stream input
                 output
                 &
                 {:keys [close-streams?] :or {close-streams? true}})

Compress given streaming input and write compressed bytes to streaming output. As input may be: File, URI, URL, Socket, byte array, or filename as String which will be coerced to BufferedInputStream and auto closed after. Output should be File, URI, URL, Socket, or filename as String which will be coerced to BufferedOutputStream and auto closed after.

Compress given streaming input and write compressed bytes to streaming output.
As input may be: File, URI, URL, Socket, byte array, or filename as String which will be
coerced to BufferedInputStream and auto closed after.
Output should be  File, URI, URL, Socket, or filename as String  which  will be
coerced to BufferedOutputStream and auto closed after.
sourceraw docstring

count-uniqueclj

(count-unique b-array)

Count unique elements in a byte array.

Count unique elements in a byte array.
sourceraw docstring

decompress-bytesclj

(decompress-bytes compressed-bytes)

Decompress bytes using Deflate Zip. Returns: byte array of plain data.

Decompress bytes using Deflate Zip.
Returns: byte array of plain data.
sourceraw docstring

decompress-streamclj

(decompress-stream input
                   output
                   &
                   {:keys [close-streams?] :or {close-streams? true}})

Decompress given streaming input and write uncompressed bytes to streaming output. As input may be: File, URI, URL, Socket, byte array, or filename as String which will be coerced to BufferedInputStream and auto closed after. Output should be File, URI, URL, Socket, or filename as String which will be coerced to BufferedOutputStream and auto closed after.

Decompress given streaming input and write uncompressed bytes to streaming output.
As input may be: File, URI, URL, Socket, byte array, or filename as String which will be
coerced to BufferedInputStream and auto closed after.
Output should be  File, URI, URL, Socket, or filename as String  which  will be
coerced to BufferedOutputStream and auto closed after.
sourceraw docstring

decrypt-and-decompress-streamclj

(decrypt-and-decompress-stream cipher
                               input
                               output
                               &
                               {:keys [close-streams?]
                                :or {close-streams? true}})

Decrypt and then decompress given streaming input and write plain data to streaming output, using given initialized ^Cipher in decryption mode. As input may be: File, URI, URL, Socket, byte array, or filename as String which will be coerced to BufferedInputStream and auto closed after. Output should be File, URI, URL, Socket, or filename as String which will be coerced to BufferedOutputStream and auto closed after.

Decrypt and then decompress given streaming input and write plain data to streaming output,
using given initialized ^Cipher in decryption mode.
As input may be: File, URI, URL, Socket, byte array, or filename as String which will be
coerced to BufferedInputStream and auto closed after.
Output should be  File, URI, URL, Socket, or filename as String  which  will be
coerced to BufferedOutputStream and auto closed after.
sourceraw docstring

decrypt-bytesclj

(decrypt-bytes cipher encrypted-bytes)

Decrypt data using given initialized ^Cipher in decryption mode. Returns plain data bytes array.

Decrypt data using given initialized ^Cipher in decryption mode.
Returns plain data bytes array.
sourceraw docstring

decrypt-streamclj

(decrypt-stream cipher
                input
                output
                &
                {:keys [close-streams?] :or {close-streams? true}})

Decrypt given streaming input and write plain data to streaming output, using given initialized ^Cipher in decryption mode. As input may be: File, URI, URL, Socket, byte array, or filename as String which will be coerced to BufferedInputStream and auto closed after. Output should be File, URI, URL, Socket, or filename as String which will be coerced to BufferedOutputStream and auto closed after.

Decrypt given streaming input and write plain data to streaming output,
using given initialized ^Cipher in decryption mode.
As input may be: File, URI, URL, Socket, byte array, or filename as String which will be
coerced to BufferedInputStream and auto closed after.
Output should be File, URI, URL, Socket, or filename as String which will be
coerced to BufferedOutputStream and auto closed after.
sourceraw docstring

encrypt-bytesclj

(encrypt-bytes cipher plain-bytes)

Encrypt plain data using given initialized ^Cipher in encryption mode. Returns encrypted bytes array.

Encrypt plain data using given initialized ^Cipher in encryption mode.
Returns encrypted bytes array.
sourceraw docstring

encrypt-streamclj

(encrypt-stream cipher
                input
                output
                &
                {:keys [close-streams?] :or {close-streams? true}})

Encrypt given streaming input and write encrypted data to streaming output, using given initialized ^Cipher in encryption mode. As input may be: File, URI, URL, Socket, byte array, or filename as String which will be coerced to BufferedInputStream and auto closed after. Output should be File, URI, URL, Socket, or filename as String which will be coerced to BufferedOutputStream and auto closed after.

Encrypt given streaming input and write encrypted data to streaming output,
using given initialized ^Cipher in encryption mode.
As input may be: File, URI, URL, Socket, byte array, or filename as String which will be
coerced to BufferedInputStream and auto closed after.
Output should be  File, URI, URL, Socket, or filename as String  which  will be
coerced to BufferedOutputStream and auto closed after.
sourceraw docstring

generate-secret-bytes-from-passwordclj

(generate-secret-bytes-from-password password-string)
(generate-secret-bytes-from-password password-string iter-count)

Generate secret key bytes using given password. Returns secret key bytes array length of 32 bytes.

Generate secret key bytes using given password.
Returns secret key bytes array length of 32 bytes.
sourceraw docstring

generate-secret-keyclj

(generate-secret-key)
(generate-secret-key algo-name)

Generate secret key using SecureRandom. By default, it generates Secret key for GOST3412-2015. Params:

  • algo-name - String, allowed values "GOST28147" or "GOST3412-2015" (default) Returns ^SecretKeySpec key
Generate secret key using SecureRandom.
By default, it generates Secret key for GOST3412-2015.
Params:
  * `algo-name` - String, allowed values "GOST28147" or "GOST3412-2015" (default)
Returns ^SecretKeySpec key
sourceraw docstring

gost28147clj

source

gost3412-2015clj

source

init-cipher-modeclj

(init-cipher-mode algo-name cipher-mode)

Init cipher mode. Returns ^Cipher. Allowed cipher modes: :cfb-mode :ctr-mode :cbc-mode

Init cipher mode. Returns ^Cipher.
Allowed cipher modes: :cfb-mode :ctr-mode :cbc-mode
sourceraw docstring

init-gost-named-paramsclj

(init-gost-named-params algo-name iv param-name)

Init algorithm using given init vector and S-Box named parameters. Returns ^AlgorithmParameterSpec - initialized GOST algorithm parameters. Allowed param names for GOST28147-89: "E-A" - Gost28147_89_CryptoPro_A_ParamSet (most used) "E-B" - Gost28147_89_CryptoPro_B_ParamSet (most used) "E-C" - Gost28147_89_CryptoPro_C_ParamSet "E-D" - Gost28147_89_CryptoPro_D_ParamSet "Param-Z" - tc26_gost_28147_param_Z

For GOST3412-2015 - param names are ignored.

Init algorithm using given init vector and S-Box named parameters.
Returns ^AlgorithmParameterSpec - initialized GOST algorithm parameters.
Allowed param names for GOST28147-89:
"E-A"     - Gost28147_89_CryptoPro_A_ParamSet (most used)
"E-B"     - Gost28147_89_CryptoPro_B_ParamSet (most used)
"E-C"     - Gost28147_89_CryptoPro_C_ParamSet
"E-D"     - Gost28147_89_CryptoPro_D_ParamSet
"Param-Z" - tc26_gost_28147_param_Z

For GOST3412-2015 - param names are ignored.
sourceraw docstring

init-gost-oid-paramsclj

(init-gost-oid-params algo-name iv oid-name)

Init algorithm using given init vector and S-Box OID parameters. Returns ^AlgorithmParameterSpec - initialized GOST algorithm parameters. For GOST3412-2015 - oid-name is ignored.

Init algorithm using given init vector and S-Box OID parameters.
Returns ^AlgorithmParameterSpec - initialized GOST algorithm parameters.
 For GOST3412-2015 - oid-name is ignored.
sourceraw docstring

init-gost-sbox-binary-paramsclj

(init-gost-sbox-binary-params algo-name iv s-box)

Init algorithm using given init vector and S-Box binary array. Returns ^AlgorithmParameterSpec - initialized GOST algorithm parameters. For GOST3412-2015 - s-box bytes are ignored.

Init algorithm using given init vector and S-Box binary array.
Returns ^AlgorithmParameterSpec - initialized GOST algorithm parameters.
 For GOST3412-2015 - s-box bytes are ignored.
sourceraw docstring

iv-length-16clj

source

iv-length-8clj

source

iv-length-by-algo-modeclj

(iv-length-by-algo-mode algo-name cipher-mode)

Return IV length by algo and cipher mode

Return IV length by algo and cipher mode
sourceraw docstring

mac-28147-streamclj

(mac-28147-stream secret-key input)
(mac-28147-stream secret-key
                  input
                  s-box
                  &
                  {:keys [close-streams?] :or {close-streams? true}})

Calculate MAC for input stream using secret-key and GOST28147. Algorithm is set inside ^SecretKeySpec. As input may be: File, URI, URL, Socket, byte array, or filename as String which will be coerced to BufferedInputStream and auto closed after. Returns byte array with calculated MAC.

Calculate MAC for input stream using secret-key and GOST28147. Algorithm is set inside ^SecretKeySpec.
As input may be: File, URI, URL, Socket, byte array, or filename as String which will be
coerced to BufferedInputStream and auto closed after.
Returns byte array with calculated MAC.
sourceraw docstring

mac-3412-streamclj

(mac-3412-stream secret-key
                 input
                 &
                 {:keys [close-streams?] :or {close-streams? true}})

Calculate MAC for input stream using secret-key and GOST3412. Algorithm is set inside ^SecretKeySpec. As input may be: File, URI, URL, Socket, byte array, or filename as String which will be coerced to BufferedInputStream and auto closed after. Returns byte array with calculated MAC.

Calculate MAC for input stream using secret-key and GOST3412. Algorithm is set inside ^SecretKeySpec.
As input may be: File, URI, URL, Socket, byte array, or filename as String which will be
coerced to BufferedInputStream and auto closed after.
Returns byte array with calculated MAC.
sourceraw docstring

mac-length-by-algoclj

(mac-length-by-algo algo-name)

Return Mac length by algo mode

Return Mac length by algo mode
sourceraw docstring

mac-length-gost28147clj

source

mac-length-gost3412-2015clj

source

mac-streamclj

(mac-stream secret-key input)
(mac-stream secret-key input s-box)

Calculate MAC for plain data stream using secret-key. Algorithm is set inside ^SecretKeySpec. As input may be: File, URI, URL, Socket, byte array, or filename as String which will be coerced to BufferedInputStream and auto closed after. Returns byte array with calculated MAC.

Calculate MAC for plain data stream using secret-key. Algorithm is set inside ^SecretKeySpec.
As input may be: File, URI, URL, Socket, byte array, or filename as String which will be
coerced to BufferedInputStream and auto closed after.
Returns byte array with calculated MAC.
sourceraw docstring

new-decryption-cipherclj

(new-decryption-cipher secret-key cipher-mode algo-params)

Create new cipher for decryption. Algorithm is set inside SecretKeySpec. Appropriate IV for decryption should be set inside ^AlgorithmParameterSpec Allowed cipher modes: :cfb-mode :ctr-mode :cbc-mode Returns ^Cipher.

Create new cipher for decryption. Algorithm is set inside SecretKeySpec.
Appropriate IV for decryption should be set inside ^AlgorithmParameterSpec
Allowed cipher modes: :cfb-mode :ctr-mode :cbc-mode
Returns ^Cipher.
sourceraw docstring

new-encryption-cipherclj

(new-encryption-cipher secret-key cipher-mode)
(new-encryption-cipher secret-key cipher-mode algo-params)

Create new cipher for encryption. Algorithm is set inside SecretKeySpec. Allowed cipher modes: :cfb-mode :ctr-mode :cbc-mode Returns ^Cipher.

Create new cipher for encryption. Algorithm is set inside SecretKeySpec.
Allowed cipher modes: :cfb-mode :ctr-mode :cbc-mode
Returns ^Cipher.
sourceraw docstring

new-ivclj

(new-iv algo-name cipher-mode)

Create new random init vector using SecureRandom for given algorithm. Allowed cipher modes: :cfb-mode :ctr-mode :cbc-mode Returns byte array appropriate length for algorithm with random data.

Create new random init vector using SecureRandom for given algorithm.
Allowed cipher modes: :cfb-mode :ctr-mode :cbc-mode
Returns byte array appropriate length for algorithm with random data.
sourceraw docstring

new-iv-16clj

(new-iv-16)

Create new random init vector using SecureRandom. Returns byte array 16 bytes length with random data.

Create new random init vector using SecureRandom.
Returns byte array 16 bytes length with random data.
sourceraw docstring

new-iv-8clj

(new-iv-8)

Create new random init vector using SecureRandom. Returns byte array 8 bytes length with random data.

Create new random init vector using SecureRandom.
Returns byte array 8 bytes length with random data.
sourceraw docstring

protect-bytesclj

(protect-bytes secret-key data)
(protect-bytes secret-key data algo-spec)

Encrypt, compress, calculate MAC for plain data. IV is always random. Encryption mode is CFB. For 28147-89 default s-box is id-Gost28147-89-CryptoPro-A-ParamSet. For GOST3412-2015 s-box is ignored. Returns bytes array with structure: [IV, encrypted(Mac), encrypted(compressed-data)]

Encrypt, compress, calculate MAC for plain data.
IV is always random. Encryption mode is CFB.
For 28147-89 default s-box is id-Gost28147-89-CryptoPro-A-ParamSet. For GOST3412-2015 s-box is ignored.
Returns bytes array with structure: [IV, encrypted(Mac), encrypted(compressed-data)]
sourceraw docstring

protect-fileclj

(protect-file secret-key input-filename output-filename)
(protect-file secret-key input-filename output-filename algo-spec)

Encrypt, compress, calculate MAC for plain data from input-filename. IV is always random. Encryption mode is CFB. For 28147-89 default s-box is id-Gost28147-89-CryptoPro-A-ParamSet. For GOST3412-2015 s-box is ignored. Save encrypted data to output-filename (create or overwrite it) with structure: [IV, encrypted(Mac), encrypted(compressed-data)]. Returns ^String value of output-filename if success or throw Exception if error.

Encrypt, compress, calculate MAC for plain data from `input-filename`.
IV is always random. Encryption mode is CFB.
For 28147-89 default s-box is id-Gost28147-89-CryptoPro-A-ParamSet. For GOST3412-2015 s-box is ignored.
Save encrypted data to `output-filename` (create or overwrite it) with structure: [IV, encrypted(Mac), encrypted(compressed-data)].
Returns ^String value of `output-filename` if success or throw Exception if error.
sourceraw docstring

s-box-crypto-pro-aclj

source

secret-key->byte-arrayclj

(secret-key->byte-array k)

Convert ^SecretKeySpec to a byte array

Convert ^SecretKeySpec to a byte array
sourceraw docstring

secret-key-length-bitsclj

Secret key length in bits

Secret key length in bits
sourceraw docstring

secret-key-length-bytesclj

Secret key length in bytes

Secret key length in bytes
sourceraw docstring

unprotect-bytesclj

(unprotect-bytes secret-key
                 input
                 &
                 {:keys [s-box] :or {s-box (byte-array s-box-crypto-pro-a)}})

Decrypt, decompress input data bytes, verify MAC for decrypted plain data. For 28147-89 default s-box is id-Gost28147-89-CryptoPro-A-ParamSet. For GOST3412-2015 s-box is ignored. Returns plain data as bytes array if success or throws Exception if failure.

Decrypt, decompress input data bytes, verify MAC for decrypted plain data.
For 28147-89 default s-box is id-Gost28147-89-CryptoPro-A-ParamSet. For GOST3412-2015 s-box is ignored.
Returns plain data as bytes array if success or throws Exception if failure.
sourceraw docstring

unprotect-fileclj

(unprotect-file secret-key
                input-filename
                output-filename
                &
                {:keys [s-box] :or {s-box (byte-array s-box-crypto-pro-a)}})

Decrypt, decompress content of input-filename, verify MAC for plain data. Save plain data to output-filename file (create or overwrite it). For 28147-89 default s-box is id-Gost28147-89-CryptoPro-A-ParamSet. For GOST3412-2015 s-box is ignored. Returns ^String value of output-filename if success or throw Exception if error.

Decrypt, decompress content of `input-filename`, verify MAC for plain data.
Save plain data to `output-filename` file (create or overwrite it).
For 28147-89 default s-box is id-Gost28147-89-CryptoPro-A-ParamSet. For GOST3412-2015 s-box is ignored.
Returns ^String value of `output-filename` if success or throw Exception if error.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close