1
<?xml version="1.0" encoding="latin1" ?>
1
<?xml version="1.0" encoding="iso-8859-1" ?>
2
2
<!DOCTYPE erlref SYSTEM "erlref.dtd">
7
<year>1999</year><year>2010</year>
7
<year>1999</year><year>2011</year>
8
8
<holder>Ericsson AB. All Rights Reserved.</holder>
285
<name>hmac_init(Type, Key) -> Context</name>
286
<fsummary></fsummary>
288
<v>Type = sha | md5 | ripemd160</v>
289
<v>Key = iolist() | binary()</v>
290
<v>Context = binary()</v>
293
<p>Initializes the context for streaming HMAC operations. <c>Type</c> determines
294
which hash function to use in the HMAC operation. <c>Key</c> is the authentication
295
key. The key can be any length.</p>
299
<name>hmac_update(Context, Data) -> NewContext</name>
300
<fsummary></fsummary>
302
<v>Context = NewContext = binary()</v>
303
<v>Data = iolist() | binary()</v>
306
<p>Updates the HMAC represented by <c>Context</c> using the given <c>Data</c>. <c>Context</c>
307
must have been generated using an HMAC init function (such as
308
<seealso marker="#hmac_init/2">hmac_init</seealso>). <c>Data</c> can be any length. <c>NewContext</c>
309
must be passed into the next call to <c>hmac_update</c>.</p>
313
<name>hmac_final(Context) -> Mac</name>
314
<fsummary></fsummary>
316
<v>Context = Mac = binary()</v>
319
<p>Finalizes the HMAC operation referenced by <c>Context</c>. The size of the resultant MAC is
320
determined by the type of hash function used to generate it.</p>
324
<name>hmac_final_n(Context, HashLen) -> Mac</name>
325
<fsummary></fsummary>
327
<v>Context = Mac = binary()</v>
328
<v>HashLen = non_neg_integer()</v>
331
<p>Finalizes the HMAC operation referenced by <c>Context</c>. <c>HashLen</c> must be greater than
332
zero. <c>Mac</c> will be a binary with at most <c>HashLen</c> bytes. Note that if HashLen is greater than the actual number of bytes returned from the underlying hash, the returned hash will have fewer than <c>HashLen</c> bytes.</p>
285
336
<name>sha_mac(Key, Data) -> Mac</name>
337
<name>sha_mac(Key, Data, MacLength) -> Mac</name>
286
338
<fsummary>Compute an <c>MD5 MAC</c>message authentification code</fsummary>
288
340
<v>Key = Data = iolist() | binary()</v>
289
341
<v>Mac = binary()</v>
342
<v>MacLenength = integer() =< 20 </v>
292
345
<p>Computes an <c>SHA MAC</c> message authentification code
293
from <c>Key</c> and <c>Data</c>, where the length of the Mac
346
from <c>Key</c> and <c>Data</c>, where the default length of the Mac
294
347
is 160 bits (20 bytes).</p>
298
351
<name>sha_mac_96(Key, Data) -> Mac</name>
299
<fsummary>Compute an <c>MD5 MAC</c>message authentification code</fsummary>
352
<fsummary>Compute an <c>SHA MAC</c>message authentification code</fsummary>
301
354
<v>Key = Data = iolist() | binary()</v>
302
355
<v>Mac = binary()</v>
409
<name>des_cfb_encrypt(Key, IVec, Text) -> Cipher</name>
410
<fsummary>Encrypt <c>Text</c>according to DES in CFB mode</fsummary>
412
<v>Key = Text = iolist() | binary()</v>
413
<v>IVec = Cipher = binary()</v>
416
<p>Encrypts <c>Text</c> according to DES in 8-bit CFB
417
mode. <c>Key</c> is the DES key, and <c>IVec</c> is an
418
arbitrary initializing vector. The lengths of <c>Key</c> and
419
<c>IVec</c> must be 64 bits (8 bytes).</p>
423
<name>des_cfb_decrypt(Key, IVec, Cipher) -> Text</name>
424
<fsummary>Decrypt <c>Cipher</c>according to DES in CFB mode</fsummary>
426
<v>Key = Cipher = iolist() | binary()</v>
427
<v>IVec = Text = binary()</v>
430
<p>Decrypts <c>Cipher</c> according to DES in 8-bit CFB mode.
431
<c>Key</c> is the DES key, and <c>IVec</c> is an arbitrary
432
initializing vector. <c>Key</c> and <c>IVec</c> must have
433
the same values as those used when encrypting. The lengths of
434
<c>Key</c> and <c>IVec</c> must be 64 bits (8 bytes).</p>
438
<name>des_cfb_ivec(IVec, Data) -> NextIVec</name>
439
<fsummary>Get <c>IVec</c> to be used in next iteration of
440
<c>des_cfb_[ecrypt|decrypt]</c></fsummary>
442
<v>IVec = iolist() | binary()</v>
443
<v>Data = iolist() | binary()</v>
444
<v>NextIVec = binary()</v>
447
<p>Returns the <c>IVec</c> to be used in a next iteration of
448
<c>des_cfb_[encrypt|decrypt]</c>. <c>IVec</c> is the vector
449
used in the previous iteration step. <c>Data</c> is the encrypted
450
data from the previous iteration step.</p>
356
454
<name>des3_cbc_encrypt(Key1, Key2, Key3, IVec, Text) -> Cipher</name>
357
455
<fsummary>Encrypt <c>Text</c>according to DES3 in CBC mode</fsummary>
372
470
<name>des3_cbc_decrypt(Key1, Key2, Key3, IVec, Cipher) -> Text</name>
373
<fsummary>Decrypt <c>Cipher</c>according to DES in CBC mode</fsummary>
471
<fsummary>Decrypt <c>Cipher</c>according to DES3 in CBC mode</fsummary>
375
473
<v>Key1 = Key2 = Key3 = Cipher = iolist() | binary()</v>
376
474
<v>IVec = Text = binary()</v>
386
484
<c>Key3</c>, and <c>IVec</c> must be 64 bits (8 bytes).</p>
488
<name>des3_cfb_encrypt(Key1, Key2, Key3, IVec, Text) -> Cipher</name>
489
<fsummary>Encrypt <c>Text</c>according to DES3 in CFB mode</fsummary>
491
<v>Key1 =Key2 = Key3 Text = iolist() | binary()</v>
492
<v>IVec = Cipher = binary()</v>
495
<p>Encrypts <c>Text</c> according to DES3 in 8-bit CFB
496
mode. <c>Key1</c>, <c>Key2</c>, <c>Key3</c>, are the DES
497
keys, and <c>IVec</c> is an arbitrary initializing
498
vector. The lengths of each of <c>Key1</c>, <c>Key2</c>,
499
<c>Key3</c> and <c>IVec</c> must be 64 bits (8 bytes).</p>
503
<name>des3_cfb_decrypt(Key1, Key2, Key3, IVec, Cipher) -> Text</name>
504
<fsummary>Decrypt <c>Cipher</c>according to DES3 in CFB mode</fsummary>
506
<v>Key1 = Key2 = Key3 = Cipher = iolist() | binary()</v>
507
<v>IVec = Text = binary()</v>
510
<p>Decrypts <c>Cipher</c> according to DES3 in 8-bit CFB mode.
511
<c>Key1</c>, <c>Key2</c>, <c>Key3</c> are the DES key, and
512
<c>IVec</c> is an arbitrary initializing vector.
513
<c>Key1</c>, <c>Key2</c>, <c>Key3</c> and <c>IVec</c> must
514
and <c>IVec</c> must have the same values as those used when
515
encrypting. The lengths of <c>Key1</c>, <c>Key2</c>,
516
<c>Key3</c>, and <c>IVec</c> must be 64 bits (8 bytes).</p>
391
521
<name>des_ecb_encrypt(Key, Text) -> Cipher</name>
419
549
<fsummary>Encrypt the first 64 bits of <c>Text</c> using Blowfish in ECB mode</fsummary>
421
551
<v>Key = Text = iolist() | binary()</v>
422
<v>IVec = Cipher = binary()</v>
552
<v>Cipher = binary()</v>
425
555
<p>Encrypts the first 64 bits of <c>Text</c> using Blowfish in ECB mode. <c>Key</c> is the Blowfish key. The length of <c>Text</c> must be at least 64 bits (8 bytes).</p>
427
559
<name>blowfish_ecb_decrypt(Key, Text) -> Cipher</name>
428
560
<fsummary>Decrypt the first 64 bits of <c>Text</c> using Blowfish in ECB mode</fsummary>
430
562
<v>Key = Text = iolist() | binary()</v>
431
<v>IVec = Cipher = binary()</v>
563
<v>Cipher = binary()</v>
434
566
<p>Decrypts the first 64 bits of <c>Text</c> using Blowfish in ECB mode. <c>Key</c> is the Blowfish key. The length of <c>Text</c> must be at least 64 bits (8 bytes).</p>
439
<name>blowfish_cbc_encrypt(Key, Text) -> Cipher</name>
571
<name>blowfish_cbc_encrypt(Key, IVec, Text) -> Cipher</name>
440
572
<fsummary>Encrypt <c>Text</c> using Blowfish in CBC mode</fsummary>
442
574
<v>Key = Text = iolist() | binary()</v>
447
579
arbitrary initializing vector. The length of <c>IVec</c>
448
580
must be 64 bits (8 bytes). The length of <c>Text</c> must be a multiple of 64 bits (8 bytes).</p>
450
<name>blowfish_cbc_decrypt(Key, Text) -> Cipher</name>
584
<name>blowfish_cbc_decrypt(Key, IVec, Text) -> Cipher</name>
451
585
<fsummary>Decrypt <c>Text</c> using Blowfish in CBC mode</fsummary>
453
587
<v>Key = Text = iolist() | binary()</v>
722
<name>aes_ctr_stream_init(Key, IVec) -> State</name>
723
<fsummary></fsummary>
725
<v>State = { K, I, E, C }</v>
726
<v>Key = K = iolist()</v>
727
<v>IVec = I = E = binary()</v>
731
<p>Initializes the state for use in streaming AES encryption using Counter mode (CTR).
732
<c>Key</c> is the AES key and must be either 128, 192, or 256 bts long. <c>IVec</c> is
733
an arbitrary initializing vector of 128 bits (16 bytes). This state is for use with
734
<seealso marker="#aes_ctr_stream_encrypt/2">aes_ctr_stream_encrypt</seealso> and
735
<seealso marker="#aes_ctr_stream_decrypt/2">aes_ctr_stream_decrypt</seealso>.</p>
739
<name>aes_ctr_stream_encrypt(State, Text) -> { NewState, Cipher}</name>
740
<fsummary></fsummary>
742
<v>Text = iolist() | binary()</v>
743
<v>Cipher = binary()</v>
746
<p>Encrypts <c>Text</c> according to AES in Counter mode (CTR). This function can be
747
used to encrypt a stream of text using a series of calls instead of requiring all
748
text to be in memory. <c>Text</c> can be any number of bytes. State is initialized using
749
<seealso marker="#aes_ctr_stream_init/2">aes_ctr_stream_init</seealso>. <c>NewState</c> is the new streaming
750
encryption state that must be passed to the next call to <c>aes_ctr_stream_encrypt</c>.
751
<c>Cipher</c> is the encrypted cipher text.</p>
755
<name>aes_ctr_stream_decrypt(State, Cipher) -> { NewState, Text }</name>
756
<fsummary></fsummary>
758
<v>Cipher = iolist() | binary()</v>
759
<v>Text = binary()</v>
762
<p>Decrypts <c>Cipher</c> according to AES in Counter mode (CTR). This function can be
763
used to decrypt a stream of ciphertext using a series of calls instead of requiring all
764
ciphertext to be in memory. <c>Cipher</c> can be any number of bytes. State is initialized using
765
<seealso marker="#aes_ctr_stream_init/2">aes_ctr_stream_init</seealso>. <c>NewState</c> is the new streaming
766
encryption state that must be passed to the next call to <c>aes_ctr_stream_encrypt</c>.
767
<c>Text</c> is the decrypted data.</p>
588
771
<name>erlint(Mpint) -> N</name>
589
772
<name>mpint(N) -> Mpint</name>
590
773
<fsummary>Convert between binary multi-precision integer and erlang big integer</fsummary>
801
<name>strong_rand_bytes(N) -> binary()</name>
802
<fsummary>Generate a binary of random bytes</fsummary>
807
<p>Generates N bytes randomly uniform 0..255, and returns the
808
result in a binary. Uses a cryptographically secure prng seeded and
809
periodically mixed with operating system provided entropy. By default
810
this is the <c>RAND_bytes</c> method from OpenSSL.</p>
811
<p>May throw exception <c>low_entropy</c> in case the random generator
812
failed due to lack of secure "randomness".</p>
618
816
<name>rand_uniform(Lo, Hi) -> N</name>
619
817
<fsummary>Generate a random number</fsummary>
625
823
<p>Generate a random number <c><![CDATA[N, Lo =< N < Hi.]]></c> Uses the
626
824
<c>crypto</c> library pseudo-random number generator. The
627
825
arguments (and result) can be either erlang integers or binary
628
multi-precision integers.</p>
826
multi-precision integers. <c>Hi</c> must be larger than <c>Lo</c>.</p>
830
<name>strong_rand_mpint(N, Top, Bottom) -> Mpint</name>
831
<fsummary>Generate an N bit random number</fsummary>
833
<v>N = non_neg_integer()</v>
834
<v>Top = -1 | 0 | 1</v>
835
<v>Bottom = 0 | 1</v>
836
<v>Mpint = binary()</v>
839
<p>Generate an N bit random number using OpenSSL's
840
cryptographically strong pseudo random number generator
842
<p>The parameter <c>Top</c> places constraints on the most
843
significant bits of the generated number. If <c>Top</c> is 1, then the
844
two most significant bits will be set to 1, if <c>Top</c> is 0, the
845
most significant bit will be 1, and if <c>Top</c> is -1 then no
846
constraints are applied and thus the generated number may be less than
848
<p>If <c>Bottom</c> is 1, then the generated number is
849
constrained to be odd.</p>
850
<p>May throw exception <c>low_entropy</c> in case the random generator
851
failed due to lack of secure "randomness".</p>
1053
<name>rc2_cbc_encrypt(Key, IVec, Text) -> Cipher</name>
1054
<fsummary>Encrypt <c>Text</c>according to RC2 in CBC mode</fsummary>
1056
<v>Key = Text = iolist() | binary()</v>
1057
<v>Ivec = Cipher = binary()</v>
1060
<p>Encrypts <c>Text</c> according to RC2 in CBC mode.</p>
1065
<name>rc2_cbc_decrypt(Key, IVec, Cipher) -> Text</name>
1066
<fsummary>Decrypts <c>Cipher</c>according to RC2 in CBC mode</fsummary>
1068
<v>Key = Text = iolist() | binary()</v>
1069
<v>Ivec = Cipher = binary()</v>
1072
<p>Decrypts <c>Cipher</c> according to RC2 in CBC mode.</p>
828
1077
<name>rc4_encrypt(Key, Data) -> Result</name>
829
1078
<fsummary>Encrypt data using RC4</fsummary>