buddy.core.crypto
Crypto engines low-level abstraction.
decrypt
(decrypt input key iv)
(decrypt input key iv {:keys [algorithm alg], :or {alg :aes128-cbc-hmac-sha256}, :as options})
Decrypt data encrypted using the encrypt
function.
The input, key and iv parameters should be of any type that can be coerced to byte array.
encrypt
(encrypt input key iv)
(encrypt input key iv {:keys [algorithm alg], :or {alg :aes128-cbc-hmac-sha256}, :as options})
Encrypt arbitrary length data using one of the supported encryption scheme. The default encryption scheme is: :aes128-cbc-hmac-sha256
.
Example: (encrypt "hello world" mykey myiv)
You can specify an other encryption scheme passing an additional parameter.
Example: (encrypt "hello world" mykey myiv {:alg :aes128-cbc-hmac-sha512})
See the documentation for know the complete list of supported encryption schemes.
The input, key and iv parameters should be of any type that can be coerced to byte array.
end!
(end! engine output offset)
End the encryption process. This is only usefull for aead block ciphers, for the rest it always return 0
and does nothing.
ICipherInit
protocol
members
-end
(-end engine out offset)
Finalize cipher engine.
-init
(-init engine params)
Initialize cipher engine.
process-block!
(process-block! engine in)
(process-block! engine in inoff out outoff)
Encrypt or decrypt a bytes using the specified engine. The length of the block to encrypt or decrypt depends on the used crypto engine.
process-bytes!
(process-bytes! engine in)
(process-bytes! engine in inoff out outoff)
(process-bytes! engine in inoff inlen out outoff)
Encrypt or decrypt a bytes using the specified engine. Is a specialized version of process-block!
for stream ciphers and aead ciphers.
split-by-blocksize
(split-by-blocksize input blocksize)
(split-by-blocksize input blocksize additional)
Split a byte array in blocksize blocks.
Given a arbitrary size bytearray and block size in bytes, returns a vector of bytearray blocks of blocksize size. If last block does not have enought data for fill all block, it is padded using zerobyte padding.