Liking cljdoc? Tell your friends :D

frereth.cp.shared.crypto

Wrap up the low-level crypto functions

Wrap up the low-level crypto functions
raw docstring

box-afterclj

(box-after shared-key plain-text length nonce)
(box-after shared-key plain-text offset length nonce)

Accept some plain text and turn it into cipher text

Accept some plain text and turn it into cipher text
raw docstring

box-prepareclj

(box-prepare public secret)

Set up shared secret so I can avoid the if logic to see whether it's been done. At least, I think that's the point.

Set up shared secret so I can avoid the if logic to see whether it's been done.
At least, I think that's the point.
raw docstring

build-boxclj

(build-box tmplt src shared-key nonce-prefix nonce-suffix)

Compose a map into bytes and encrypt it

Note that tmplt should not include the requisite 32 bytes of 0 padding

Compose a map into bytes and encrypt it

Note that tmplt should *not* include the requisite 32 bytes of 0 padding
raw docstring

build-random-ivclj

(build-random-iv n)

decompose-boxclj

(decompose-box log-state tmplt nonce-prefix nonce-suffix crypto-box shared-key)

Open a crypto box and decompose its bytes

Open a crypto box and decompose its bytes
raw docstring

do-load-keypairclj

(do-load-keypair keydir)

Honestly, these should be stored with something like base64 encoding

Honestly, these should be stored with something like base64 encoding
raw docstring

do-safe-nonceclj

(do-safe-nonce log-state dst offset)
(do-safe-nonce log-state dst key-dir offset long-term?)

Shoves a theoretically safe 16-byte nonce suffix into dst at offset

Shoves a theoretically safe 16-byte nonce suffix into dst at offset
raw docstring

encrypt-blockclj

(encrypt-block secret-key clear-text)

Block-encrypt a byte-array

Block-encrypt a byte-array
raw docstring

generate-symmetric-keyclj

(generate-symmetric-key bit-size)
(generate-symmetric-key algorithm bit-size)

get-nonce-agent-stateclj

(get-nonce-agent-state)

get-random-bytesclj

(get-random-bytes n)

get-safe-client-nonce-suffixclj

(get-safe-client-nonce-suffix log-state)

Get a new byte array containing the next client nonce suffix

Get a new byte array containing the next client nonce suffix
raw docstring

get-safe-server-nonce-suffixclj

(get-safe-server-nonce-suffix log-state)

Get a new byte array containing the next server nonce suffix

Get a new byte array containing the next server nonce suffix
raw docstring

initial-nonce-agent-stateclj

(initial-nonce-agent-state)

load-nonce-keyclj

(load-nonce-key {:keys [:frereth.cp.shared.crypto/key-loaded?] :as this}
                key-dir)

new-nonce-key!clj

(new-nonce-key! key-dir)

Generates a new secret nonce key and stores it under key-dir

Generates a new secret nonce key and stores it under key-dir
raw docstring

nonce-key-lengthclj


obscure-nonceclj

(obscure-nonce {:keys [:frereth.cp.shared.crypto/counter-low
                       :frereth.cp.shared.crypto/data
                       :frereth.cp.shared.crypto/nonce-key]
                :as this}
               random-portion)

More side effects. Encrypt and increment the nonce counter

More side effects. Encrypt and increment the nonce counter
raw docstring

open-afterclj

(open-after log-state box box-offset box-length nonce shared-key)

Low-level direct crypto box opening

@parameter box: crypto box byte array to open @parameter box-offset: first byte of box to start opening @parameter box-length: how many bytes of box to open @parameter nonce: Number used Once for this specific box @parameter shared-key: combination of their-public and my-private

Note that this does cope with the extra required 16 bytes of prefix padding

The parameter order is screwy to match the java API.

Which was probably modeled to match the C API.

It's annoying and subject to change at a a whim. The only reason it hasn't yet is that I'm giving this entire translation the white-glove treatment.

If nothing else, the shared-key should come first to match the instance-level API and allow me to set it up as a partial.

It would also be nice to be able to provide a reusable buffer byte array destination that could just be reused without GC.

That looks like it would get into the gory implementation details which I'm really not qualified to touch.

And it would be premature optimization

Low-level direct crypto box opening

@parameter box: crypto box byte array to open
@parameter box-offset: first byte of box to start opening
@parameter box-length: how many bytes of box to open
@parameter nonce: Number used Once for this specific box
@parameter shared-key: combination of their-public and my-private

Note that this does cope with the extra required 16 bytes of prefix padding

The parameter order is screwy to match the java API.

Which was probably modeled to match the C API.

It's annoying and subject to change at a a whim. The only
reason it hasn't yet is that I'm giving this entire translation
the white-glove treatment.

If nothing else, the shared-key should come first to match the
instance-level API and allow me to set it up as a partial.

It would also be nice to be able to provide a reusable buffer byte
array destination that could just be reused without GC.

That looks like it would get into the gory implementation details
which I'm really not qualified to touch.

And it would be premature optimization
raw docstring

open-boxclj

(open-box log-state nonce-prefix nonce-suffix crypto-box shared-key)

Builds a nonce and open a crypto box

Builds a nonce and open a crypto box
raw docstring

random-arrayclj

(random-array n)

Returns an array of n random bytes

Returns an array of n random bytes
raw docstring

random-bytes!clj

(random-bytes! dst)

Fills dst with random bytes

Fills dst with random bytes
raw docstring

random-keyclj

(random-key)

Returns a byte array suitable for use as a random key

Returns a byte array suitable for use as a random key
raw docstring

random-key-pairclj

(random-key-pair)

Generates a pair of random keys

Generates a pair of random keys
raw docstring

random-keysclj

(random-keys which)

Sticks a new random key pair into a map

Sticks a new random key pair into a map
raw docstring

random-modclj

(random-mod denominator)

Picks a big random number and securely

Picks a big random number and securely 
raw docstring

random-nonceclj

(random-nonce)

Generates a number suitable for use as a cryptographically secure random nonce

Generates a number suitable for use as a cryptographically secure random nonce
raw docstring

randomize-buffer!clj

(randomize-buffer! dst)

Fills the bytes of dst with crypto-random ints

Fills the bytes of dst with crypto-random ints
raw docstring

reload-nonceclj

(reload-nonce {:keys [:frereth.cp.shared.crypto/counter-low
                      :frereth.cp.shared.crypto/counter-high]
               data :frereth.cp.shared.crypto/data
               :as this}
              key-dir
              long-term?)

Do this inside an agent for thread safety

Do this inside an agent for thread safety
raw docstring

reset-safe-nonce-state!clj

(reset-safe-nonce-state!)

secret-boxclj

(secret-box cleartext length nonce key)

Symmetric encryption

Note that this does not do anything about the initial padding.

It may be an implementation detail, but box-after above is really just a wrapper around this

Symmetric encryption

Note that this does not do anything about the initial padding.

It may be an implementation detail, but box-after above is really
just a wrapper around this
raw docstring

secret-unboxclj

(secret-unbox cipher-text length nonce key)

Symmetric-key decryption

Symmetric-key decryption
raw docstring

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

× close