sleeping_kangaroo12 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7453def4dc8a8e3a1c2969eae931609fea5407fdba11a56e8e14fd5a09325b5f
4
- data.tar.gz: ad708b12872beef715a367ba32ecefb0c869fb969a88df41a15fc3cac7379f43
3
+ metadata.gz: 43f29b860cf5a2c6dc1fac237ebbc490a309277f7e61fcaa078a2f0c097b6a26
4
+ data.tar.gz: 96f53173416460a9a64decd3312a5c613bf3875a68bec5bb43d8cfdb834c4517
5
5
  SHA512:
6
- metadata.gz: 1ec13969d3b64f83c29a4b2b7653cc080f442b0818f9e5f818fd2c8ca139b658f9692832f9d9a046320cf16d5988240c06bddc5fd3de3ce0faa920b1af0abb56
7
- data.tar.gz: 748c612b41ff1460dad89f1e122b466cb052089d95eb552557c6f0ef229ce74ad5d214e9f5d371464dc93aaa65db412af284dafbb83eb62d5bccab413943f84b
6
+ metadata.gz: 7c49649a2576b01241565d83c77e7738eec932239cda39a59cadefffaf3820d996487db856d4c7bc63c00f1b698b832bc871c8627483754bf8ee9a216df113df
7
+ data.tar.gz: 67cd342201f52cd5c94a4a35d2df005b942d3e1ca2ec5a0eb9b56e36644b996842ce4788635507460cf3f9e3dd92761d6e269224862875f9caf4d23220ce9ed7
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ lib/**/digest.rb
2
+ -
3
+ README.md
4
+ LICENSE.md
data/README.md CHANGED
@@ -45,6 +45,12 @@ In order to install the gem, your machine should be ready to build the K12 packa
45
45
  - xsltproc executable, normally comes with libxslt package
46
46
  - Ruby related stuffs
47
47
 
48
+ ### TL;DR for Ubuntu-liked OS
49
+
50
+ ~~~bash
51
+ sudo apt install build-essential xsltproc
52
+ ~~~
53
+
48
54
  ## Installation
49
55
 
50
56
  Add this line to your application's Gemfile:
@@ -53,7 +59,7 @@ Add this line to your application's Gemfile:
53
59
  gem 'sleeping_kangaroo12'
54
60
  ~~~
55
61
 
56
- And then execute:
62
+ Check the [prerequisites](#prerequisites); and then execute:
57
63
 
58
64
  $ bundle install
59
65
 
@@ -47,7 +47,7 @@ static void KangarooTwelve_F_Absorb(KangarooTwelve_F *instance, const unsigned c
47
47
  i = 0;
48
48
  curData = data;
49
49
  while(i < dataByteLen) {
50
- if ((instance->byteIOIndex == 0) && (dataByteLen >= (i + rateInBytes))) {
50
+ if ((instance->byteIOIndex == 0) && (dataByteLen-i >= rateInBytes)) {
51
51
  #ifdef KeccakP1600_12rounds_FastLoop_supported
52
52
  /* processing full blocks first */
53
53
  j = KeccakP1600_12rounds_FastLoop_Absorb(instance->state, K12_rateInLanes, curData, dataByteLen - i);
@@ -62,7 +62,7 @@ static void KangarooTwelve_F_Absorb(KangarooTwelve_F *instance, const unsigned c
62
62
  i = dataByteLen - j;
63
63
  } else {
64
64
  /* normal lane: using the message queue */
65
- if ((dataByteLen - i) + instance->byteIOIndex > (size_t)rateInBytes) {
65
+ if (dataByteLen - i > (size_t)rateInBytes - instance->byteIOIndex) {
66
66
  partialBlock = rateInBytes-instance->byteIOIndex;
67
67
  } else {
68
68
  partialBlock = (uint8_t)(dataByteLen - i);
@@ -112,7 +112,7 @@ static void KangarooTwelve_F_Squeeze(KangarooTwelve_F *instance, unsigned char *
112
112
  i = 0;
113
113
  curData = data;
114
114
  while(i < dataByteLen) {
115
- if ((instance->byteIOIndex == rateInBytes) && (dataByteLen >= (i + rateInBytes))) {
115
+ if ((instance->byteIOIndex == rateInBytes) && (dataByteLen-i >= rateInBytes)) {
116
116
  for(j=dataByteLen-i; j>=rateInBytes; j-=rateInBytes) {
117
117
  KeccakP1600_Permute_12rounds(instance->state);
118
118
  KeccakP1600_ExtractBytes(instance->state, curData, 0, rateInBytes);
@@ -125,9 +125,10 @@ static void KangarooTwelve_F_Squeeze(KangarooTwelve_F *instance, unsigned char *
125
125
  KeccakP1600_Permute_12rounds(instance->state);
126
126
  instance->byteIOIndex = 0;
127
127
  }
128
- partialBlock = (unsigned int)(dataByteLen - i);
129
- if (partialBlock+instance->byteIOIndex > rateInBytes)
128
+ if (dataByteLen-i > rateInBytes-instance->byteIOIndex)
130
129
  partialBlock = rateInBytes-instance->byteIOIndex;
130
+ else
131
+ partialBlock = (unsigned int)(dataByteLen - i);
131
132
  i += partialBlock;
132
133
 
133
134
  KeccakP1600_ExtractBytes(instance->state, curData, instance->byteIOIndex, partialBlock);
@@ -33,8 +33,8 @@ Please refer to the XKCP for more details.
33
33
  #define ROL64in256(d, a, o) d = _mm256_or_si256(_mm256_slli_epi64(a, o), _mm256_srli_epi64(a, 64-(o)))
34
34
  #define ROL64in256_8(d, a) d = _mm256_shuffle_epi8(a, CONST256(rho8))
35
35
  #define ROL64in256_56(d, a) d = _mm256_shuffle_epi8(a, CONST256(rho56))
36
- static const uint64_t rho8[4] ALIGN(32) = {0x0605040302010007, 0x0E0D0C0B0A09080F, 0x1615141312111017, 0x1E1D1C1B1A19181F};
37
- static const uint64_t rho56[4] ALIGN(32) = {0x0007060504030201, 0x080F0E0D0C0B0A09, 0x1017161514131211, 0x181F1E1D1C1B1A19};
36
+ static ALIGN(AVX2alignment) const uint64_t rho8[4] = {0x0605040302010007, 0x0E0D0C0B0A09080F, 0x1615141312111017, 0x1E1D1C1B1A19181F};
37
+ static ALIGN(AVX2alignment) const uint64_t rho56[4] = {0x0007060504030201, 0x080F0E0D0C0B0A09, 0x1017161514131211, 0x181F1E1D1C1B1A19};
38
38
  #define STORE256(a, b) _mm256_store_si256((__m256i *)&(a), b)
39
39
  #define STORE256u(a, b) _mm256_storeu_si256((__m256i *)&(a), b)
40
40
  #define XOR256(a, b) _mm256_xor_si256(a, b)
@@ -52,33 +52,37 @@ http://creativecommons.org/publicdomain/zero/1.0/
52
52
  </xsl:template>
53
53
 
54
54
  <xsl:template match="gcc">
55
- <!-- What follows is a shameless hack to avoid -march=native on aarch64 with clang -->
56
- <xsl:if test=".= '-march=native'">
57
- <xsl:text>ifneq ($(UNAME_M)$(findstring clang,$(CC)),aarch64clang)
55
+ <!-- What follows is a shameless hack to avoid -march/-mtune=native on arm64/aarch64 with clang -->
56
+ <xsl:if test=".= '-march=native' or .= '-mtune=native'">
57
+ <xsl:text>ifneq ($(UNAME_M),aarch64)
58
+ ifneq ($(UNAME_S),Darwin)
58
59
  </xsl:text>
59
60
  </xsl:if>
60
61
  <xsl:text>CFLAGS := $(CFLAGS) </xsl:text>
61
62
  <xsl:value-of select="."/>
62
63
  <xsl:text>
63
64
  </xsl:text>
64
- <xsl:if test=".= '-march=native'">
65
+ <xsl:if test=".= '-march=native' or .= '-mtune=native'">
65
66
  <xsl:text>endif
67
+ endif
66
68
  </xsl:text>
67
69
  </xsl:if>
68
70
  </xsl:template>
69
71
 
70
72
  <xsl:template match="gas">
71
- <!-- What follows is a shameless hack to avoid -march=native on aarch64 with clang -->
72
- <xsl:if test=".= '-march=native'">
73
- <xsl:text>ifneq ($(UNAME_M)$(findstring clang,$(CC)),aarch64clang)
73
+ <!-- What follows is a shameless hack to avoid -march/-mtune=native on arm64/aarch64 with clang -->
74
+ <xsl:if test=".= '-march=native' or .= '-mtune=native'">
75
+ <xsl:text>ifneq ($(UNAME_M),aarch64)
76
+ ifneq ($(UNAME_S),Darwin)
74
77
  </xsl:text>
75
78
  </xsl:if>
76
79
  <xsl:text>ASMFLAGS := $(ASMFLAGS) </xsl:text>
77
80
  <xsl:value-of select="."/>
78
81
  <xsl:text>
79
82
  </xsl:text>
80
- <xsl:if test=".= '-march=native'">
83
+ <xsl:if test=".= '-march=native' or .= '-mtune=native'">
81
84
  <xsl:text>endif
85
+ endif
82
86
  </xsl:text>
83
87
  </xsl:if>
84
88
  </xsl:template>
@@ -200,9 +204,11 @@ ifeq ($(UNAME_S),Linux)
200
204
  ASMFLAGS :=
201
205
  endif
202
206
  ifeq ($(UNAME_S),Darwin)
203
- ASMFLAGS := -x assembler-with-cpp -Wa,-defsym,macOS=1
207
+ ASMFLAGS := -x assembler-with-cpp -Wa,-defsym,old_gas_syntax=1 -Wa,-defsym,no_plt=1
208
+ endif
209
+ ifneq (,$(findstring mingw32,$(CC)))
210
+ ASMFLAGS := -x assembler-with-cpp -Wa,-defsym,old_gas_syntax=1 -Wa,-defsym,no_plt=1
204
211
  endif
205
-
206
212
  UNAME_M := $(shell uname -m)
207
213
 
208
214
  </xsl:text>
@@ -3,7 +3,6 @@
3
3
  require_relative 'build/loader'
4
4
 
5
5
  module SleepingKangaroo12
6
- # @!visibility private
7
6
  module Binding
8
7
  extend ::FFI::Library
9
8
  ffi_lib Build::Loader.find('SleepingKangaroo12')
@@ -5,7 +5,6 @@ require 'pathname'
5
5
  require_relative 'platform'
6
6
 
7
7
  module SleepingKangaroo12
8
- # @!visibility private
9
8
  module Build
10
9
  # taken from:
11
10
  # https://github.com/ffi/ffi-compiler/blob/master/lib/ffi-compiler/loader.rb
@@ -4,11 +4,9 @@ require 'ffi'
4
4
  require 'singleton'
5
5
 
6
6
  module SleepingKangaroo12
7
- # @!visibility private
8
7
  module Build
9
8
  # mostly taken from:
10
9
  # https://github.com/ffi/ffi-compiler/blob/master/lib/ffi-compiler/platform.rb
11
-
12
10
  class Platform
13
11
  include ::Singleton
14
12
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SleepingKangaroo12
4
- VERSION = '0.0.5'
4
+ VERSION = '0.0.6'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sleeping_kangaroo12
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sarun Rattanasiri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-18 00:00:00.000000000 Z
11
+ date: 2022-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -62,6 +62,7 @@ extensions:
62
62
  - ext/Rakefile
63
63
  extra_rdoc_files: []
64
64
  files:
65
+ - ".yardopts"
65
66
  - LICENSE.md
66
67
  - README.md
67
68
  - ext/Rakefile
@@ -107,8 +108,8 @@ licenses:
107
108
  - BSD-3-Clause
108
109
  metadata:
109
110
  homepage_uri: https://github.com/the-cave/sleeping-kangaroo12
110
- source_code_uri: https://github.com/the-cave/sleeping-kangaroo12/tree/v0.0.5
111
- documentation_uri: https://rubydoc.info/gems/sleeping_kangaroo12/0.0.5
111
+ source_code_uri: https://github.com/the-cave/sleeping-kangaroo12/tree/v0.0.6
112
+ documentation_uri: https://rubydoc.info/gems/sleeping_kangaroo12/0.0.6
112
113
  bug_tracker_uri: https://github.com/the-cave/sleeping-kangaroo12/issues
113
114
  post_install_message:
114
115
  rdoc_options: []
@@ -125,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
126
  - !ruby/object:Gem::Version
126
127
  version: '0'
127
128
  requirements: []
128
- rubygems_version: 3.2.32
129
+ rubygems_version: 3.3.7
129
130
  signing_key:
130
131
  specification_version: 4
131
132
  summary: KangarooTwelve, the hash algorithm, native binding for Ruby