sha3 0.2.6 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sha3 might be problematic. Click here for more details.

Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.travis.yml +9 -1
  4. data/Gemfile.ci +4 -4
  5. data/LICENSE.txt +1 -1
  6. data/README.md +145 -0
  7. data/Rakefile +4 -5
  8. data/ext/sha3/KeccakF-1600-interface.h +28 -34
  9. data/ext/sha3/KeccakHash.c +80 -0
  10. data/ext/sha3/KeccakHash.h +110 -0
  11. data/ext/sha3/KeccakSponge.c +127 -201
  12. data/ext/sha3/KeccakSponge.h +74 -37
  13. data/ext/sha3/Optimized64/KeccakF-1600-64.macros +2199 -0
  14. data/ext/sha3/Optimized64/KeccakF-1600-opt64-settings.h +3 -0
  15. data/ext/sha3/Optimized64/KeccakF-1600-opt64.c +508 -0
  16. data/ext/sha3/{KeccakF-1600-unrolling.macros → Optimized64/KeccakF-1600-unrolling.macros} +16 -14
  17. data/ext/sha3/Optimized64/SnP-interface.h +47 -0
  18. data/ext/sha3/Reference/KeccakF-1600-reference.c +311 -0
  19. data/ext/sha3/Reference/KeccakF-reference.h +26 -0
  20. data/ext/sha3/Reference/SnP-FBWL-default.c +96 -0
  21. data/ext/sha3/Reference/SnP-FBWL-default.h +26 -0
  22. data/ext/sha3/Reference/SnP-interface.h +42 -0
  23. data/ext/sha3/{displayIntermediateValues.c → Reference/displayIntermediateValues.c} +52 -11
  24. data/ext/sha3/{displayIntermediateValues.h → Reference/displayIntermediateValues.h} +11 -6
  25. data/ext/sha3/SnP-Relaned.h +249 -0
  26. data/ext/sha3/brg_endian.h +0 -0
  27. data/ext/sha3/digest.c +67 -70
  28. data/ext/sha3/digest.h +2 -2
  29. data/ext/sha3/extconf.rb +7 -12
  30. data/ext/sha3/sha3.h +2 -2
  31. data/lib/sha3/doc.rb +26 -39
  32. data/lib/sha3/version.rb +2 -2
  33. data/sha3.gemspec +6 -6
  34. data/spec/generate_tests.rb +6 -41
  35. data/spec/sha3_core_spec.rb +111 -133
  36. data/spec/spec_helper.rb +2 -2
  37. data/tests.sh +9 -7
  38. metadata +33 -36
  39. data/README.rdoc +0 -131
  40. data/ext/sha3/KeccakF-1600-32-rvk.macros +0 -555
  41. data/ext/sha3/KeccakF-1600-32-s1.macros +0 -1187
  42. data/ext/sha3/KeccakF-1600-32-s2.macros +0 -1187
  43. data/ext/sha3/KeccakF-1600-32.macros +0 -26
  44. data/ext/sha3/KeccakF-1600-64.macros +0 -728
  45. data/ext/sha3/KeccakF-1600-int-set.h +0 -6
  46. data/ext/sha3/KeccakF-1600-opt.c +0 -504
  47. data/ext/sha3/KeccakF-1600-opt32-settings.h +0 -4
  48. data/ext/sha3/KeccakF-1600-opt32.c-arch +0 -524
  49. data/ext/sha3/KeccakF-1600-opt64-settings.h +0 -7
  50. data/ext/sha3/KeccakF-1600-opt64.c-arch +0 -504
  51. data/ext/sha3/KeccakF-1600-reference.c-arch +0 -300
  52. data/ext/sha3/KeccakF-1600-x86-64-gas.s +0 -766
  53. data/ext/sha3/KeccakF-1600-x86-64-shld-gas.s +0 -766
  54. data/ext/sha3/KeccakNISTInterface.c +0 -81
  55. data/ext/sha3/KeccakNISTInterface.h +0 -70
@@ -1,81 +0,0 @@
1
- /*
2
- The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
3
- Michaël Peeters and Gilles Van Assche. For more information, feedback or
4
- questions, please refer to our website: http://keccak.noekeon.org/
5
-
6
- Implementation by the designers,
7
- hereby denoted as "the implementer".
8
-
9
- To the extent possible under law, the implementer has waived all copyright
10
- and related or neighboring rights to the source code in this file.
11
- http://creativecommons.org/publicdomain/zero/1.0/
12
- */
13
-
14
- #include <string.h>
15
- #include "KeccakNISTInterface.h"
16
- #include "KeccakF-1600-interface.h"
17
-
18
- HashReturn Init(hashState *state, int hashbitlen)
19
- {
20
- switch(hashbitlen) {
21
- case 0: // Default parameters, arbitrary length output
22
- InitSponge((spongeState*)state, 1024, 576);
23
- break;
24
- case 224:
25
- InitSponge((spongeState*)state, 1152, 448);
26
- break;
27
- case 256:
28
- InitSponge((spongeState*)state, 1088, 512);
29
- break;
30
- case 384:
31
- InitSponge((spongeState*)state, 832, 768);
32
- break;
33
- case 512:
34
- InitSponge((spongeState*)state, 576, 1024);
35
- break;
36
- default:
37
- return BAD_HASHLEN;
38
- }
39
- state->fixedOutputLength = hashbitlen;
40
- return SUCCESS;
41
- }
42
-
43
- HashReturn Update(hashState *state, const BitSequence *data, DataLength databitlen)
44
- {
45
- if ((databitlen % 8) == 0)
46
- return Absorb((spongeState*)state, data, databitlen);
47
- else {
48
- HashReturn ret = Absorb((spongeState*)state, data, databitlen - (databitlen % 8));
49
- if (ret == SUCCESS) {
50
- unsigned char lastByte;
51
- // Align the last partial byte to the least significant bits
52
- lastByte = data[databitlen/8] >> (8 - (databitlen % 8));
53
- return Absorb((spongeState*)state, &lastByte, databitlen % 8);
54
- }
55
- else
56
- return ret;
57
- }
58
- }
59
-
60
- HashReturn Final(hashState *state, BitSequence *hashval)
61
- {
62
- return Squeeze(state, hashval, state->fixedOutputLength);
63
- }
64
-
65
- HashReturn Hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval)
66
- {
67
- hashState state;
68
- HashReturn result;
69
-
70
- if ((hashbitlen != 224) && (hashbitlen != 256) && (hashbitlen != 384) && (hashbitlen != 512))
71
- return BAD_HASHLEN; // Only the four fixed output lengths available through this API
72
- result = Init(&state, hashbitlen);
73
- if (result != SUCCESS)
74
- return result;
75
- result = Update(&state, data, databitlen);
76
- if (result != SUCCESS)
77
- return result;
78
- result = Final(&state, hashval);
79
- return result;
80
- }
81
-
@@ -1,70 +0,0 @@
1
- /*
2
- The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
3
- Michaël Peeters and Gilles Van Assche. For more information, feedback or
4
- questions, please refer to our website: http://keccak.noekeon.org/
5
-
6
- Implementation by the designers,
7
- hereby denoted as "the implementer".
8
-
9
- To the extent possible under law, the implementer has waived all copyright
10
- and related or neighboring rights to the source code in this file.
11
- http://creativecommons.org/publicdomain/zero/1.0/
12
- */
13
-
14
- #ifndef _KeccakNISTInterface_h_
15
- #define _KeccakNISTInterface_h_
16
-
17
- #include "KeccakSponge.h"
18
-
19
- typedef unsigned char BitSequence;
20
- typedef unsigned long long DataLength;
21
- typedef enum { SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2 } HashReturn;
22
-
23
- typedef spongeState hashState;
24
-
25
- /**
26
- * Function to initialize the state of the Keccak[r, c] sponge function.
27
- * The rate r and capacity c values are determined from @a hashbitlen.
28
- * @param state Pointer to the state of the sponge function to be initialized.
29
- * @param hashbitlen The desired number of output bits,
30
- * or 0 for Keccak[] with default parameters
31
- * and arbitrarily-long output.
32
- * @pre The value of hashbitlen must be one of 0, 224, 256, 384 and 512.
33
- * @return SUCCESS if successful, BAD_HASHLEN if the value of hashbitlen is incorrect.
34
- */
35
- HashReturn Init(hashState *state, int hashbitlen);
36
- /**
37
- * Function to give input data for the sponge function to absorb.
38
- * @param state Pointer to the state of the sponge function initialized by Init().
39
- * @param data Pointer to the input data.
40
- * When @a databitLen is not a multiple of 8, the last bits of data must be
41
- * in the most significant bits of the last byte.
42
- * @param databitLen The number of input bits provided in the input data.
43
- * @pre In the previous call to Absorb(), databitLen was a multiple of 8.
44
- * @return SUCCESS if successful, FAIL otherwise.
45
- */
46
- HashReturn Update(hashState *state, const BitSequence *data, DataLength databitlen);
47
- /**
48
- * Function to squeeze output data from the sponge function.
49
- * If @a hashbitlen was not 0 in the call to Init(), the number of output bits is equal to @a hashbitlen.
50
- * If @a hashbitlen was 0 in the call to Init(), the output bits must be extracted using the Squeeze() function.
51
- * @param state Pointer to the state of the sponge function initialized by Init().
52
- * @param hashval Pointer to the buffer where to store the output data.
53
- * @return SUCCESS if successful, FAIL otherwise.
54
- */
55
- HashReturn Final(hashState *state, BitSequence *hashval);
56
- /**
57
- * Function to compute a hash using the Keccak[r, c] sponge function.
58
- * The rate r and capacity c values are determined from @a hashbitlen.
59
- * @param hashbitlen The desired number of output bits.
60
- * @param data Pointer to the input data.
61
- * When @a databitLen is not a multiple of 8, the last bits of data must be
62
- * in the most significant bits of the last byte.
63
- * @param databitLen The number of input bits provided in the input data.
64
- * @param hashval Pointer to the buffer where to store the output data.
65
- * @pre The value of hashbitlen must be one of 224, 256, 384 and 512.
66
- * @return SUCCESS if successful, BAD_HASHLEN if the value of hashbitlen is incorrect.
67
- */
68
- HashReturn Hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval);
69
-
70
- #endif