Changeset 35090 in project


Ignore:
Timestamp:
01/30/18 02:01:09 (9 months ago)
Author:
chust
Message:

[tweetnacl] Documented pseudo-random stream functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/tweetnacl

    r35066 r35090  
    103103<procedure>(make-symmetric-box-key [entropy-port (current-entropy-port)])</procedure>
    104104
    105 Generate a new key for symmetric boxing. Reads data from {{entropy-port}}. Returns a blobs representing the new shared key.
     105Generate a new key for symmetric boxing. Reads data from {{entropy-port}}. Returns a blob representing the new shared key.
    106106
    107107<procedure>(derive-symmetric-box-key pk sk)</procedure>
     
    145145Decrypt and verify a message {{sm}} using the shared key {{k}}. The signature message combination {{sm}} and the returned plaintext are represented as strings. If the authenticity of the message cannot be verified the procedure returns {{#f}} instead of a string. If {{m}} is given and not {{#f}} it must be a string containing the plaintext of the message and {{sm}} is expected to only contain the message authentication tag in that case.
    146146
     147==== Pseudo-Random Streams
     148
     149<constant>random-stream-primitive</constant>
     150
     151A string that briefly describes the algorithm combination used to implement pseudo-random streams.
     152
     153<constant>random-stream-keybytes</constant>
     154
     155The size of shared keys for pseudo-random streams in bytes.
     156
     157<constant>random-stream-noncebytes</constant>
     158
     159The size of nonces for pseudo-random streams in bytes.
     160
     161<procedure>(make-random-stream-key [entropy-port (current-entropy-port)])</procedure>
     162
     163Generate a new key for pseudo-random streams. Reads data from {{entropy-port}}. Returns a blob representing the new shared key.
     164
     165<procedure>(derive-random-stream-key pk sk)</procedure>
     166
     167Derive a new key for pseudo-random streams from secret key {{sk}} to public key {{pk}}.
     168
     169<procedure>(open-random-stream k n #!optional [limit most-positive-fixnum])</procedure>
     170
     171Open a stream of pseudo-random bytes using the shared key {{k}} and nonce {{n}} for algorithm randomization. The stream ends after {{limit}} bytes.
     172
     173<procedure>(stream-xor! buffer #!optional [stream (current-input-port)])</procedure>
     174
     175Destructively xors the contents of the string {{buffer}} with bytes read from {{stream}}. Returns {{buffer}}.
     176
     177<procedure>(stream-xor buffer #!optional [stream (current-input-port)])</procedure>
     178
     179Xors the contents of the string {{buffer}} with bytes read from {{stream}}. Returns a new string holding the result.
     180
    147181==== Miscellaneous
    148182
     
    161195<parameter>current-entropy-port</parameter>
    162196
    163 An input port connected to an entropy source for key generation. When compiled on a unix system, this parameter is by default bound to the result of {{(open-input-file "/dev/random")}}. When compiled on a windows system, the default value of the parameter is a custom input port that returns bytes produced by [[https://msdn.microsoft.com/en-us/library/aa387694.aspx|RtlGenRandom]]. On other systems the default value of the parameter will be {{#f}} and you will have to set it explicitly before key generation functions can be used.
     197An input port connected to an entropy source for key generation.
     198
     199When compiled on a unix system, this parameter is by default bound to the result of {{(open-input-file "/dev/random")}}. When compiled on a windows system, the default value of the parameter is a custom input port that returns bytes produced by [[https://msdn.microsoft.com/en-us/library/aa387694.aspx|RtlGenRandom]]. On other systems the default value of the parameter will be {{#f}} and you will have to set it explicitly before key generation functions can be used.
     200
     201To speed up key generation it can be useful to set {{current-entropy-port}} to a pseudo-random stream only seeded initially from the system entropy source:
     202
     203  (current-entropy-port (open-random-stream (make-random-stream-key) (make-u8vector random-stream-noncebytes 0)))
Note: See TracChangeset for help on using the changeset viewer.