blake2 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +10 -1
- data/blake2.gemspec +1 -1
- data/certs/franckverrot.pem +16 -16
- data/ext/blake2_ext/rbext.c +54 -42
- data/lib/blake2/key.rb +3 -3
- metadata +19 -20
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4250cbe6cd64da1a6b5a975ad4723dc257cb08b3
|
4
|
+
data.tar.gz: 06f89ae5b24e3a63536cf7718490c12624e0b05b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c963fd93b7772aa6c39e476b635568b10d521959b67b8d6ee1019707b2a18e3c66c9b09c2047f009785caf47fac9069ce40669fde646909fbceeac3a564e00a
|
7
|
+
data.tar.gz: 37fefa3f64d105717495ac62c10a12b3f85e551146c8d455be2d0e3577a41e3cc2fdd7d8cc21b27cc80ef8bcd0df71556c2f2a007bb01dc6fa46edf5873adf6b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
data/blake2.gemspec
CHANGED
data/certs/franckverrot.pem
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
2
|
MIIDaDCCAlCgAwIBAgIBATANBgkqhkiG9w0BAQUFADA9MQ8wDQYDVQQDDAZmcmFu
|
3
3
|
Y2sxFjAUBgoJkiaJk/IsZAEZFgZ2ZXJyb3QxEjAQBgoJkiaJk/IsZAEZFgJmcjAe
|
4
|
-
|
4
|
+
Fw0xNjA1MTMxOTQ3NTlaFw0xNzA1MTMxOTQ3NTlaMD0xDzANBgNVBAMMBmZy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ObAUyUv1oiyb
|
18
|
+
PEaDVSbqqbtwQAsY87Vam7GUcH/IJnhdLadvNOJlLr8jxW+gm1ZFE9MOlsSmHeGe
|
19
|
+
Z7BoH/Mfxw3P4yyir173p9JWvVqLiQE13XBeD13NPA8neoWpLJxm6k03PcTElT/E
|
20
|
+
QrOSgKrHAb/fFJma
|
21
21
|
-----END CERTIFICATE-----
|
data/ext/blake2_ext/rbext.c
CHANGED
@@ -4,89 +4,101 @@
|
|
4
4
|
|
5
5
|
typedef struct {
|
6
6
|
uint8_t key_length;
|
7
|
-
uint8_t *
|
7
|
+
uint8_t *key_bytes;
|
8
8
|
|
9
9
|
uint8_t output_length;
|
10
10
|
uint8_t *output;
|
11
|
+
|
12
|
+
VALUE to_hex;
|
13
|
+
VALUE to_bytes;
|
11
14
|
} Blake2;
|
12
15
|
|
13
|
-
|
14
|
-
{
|
15
|
-
int i;
|
16
|
-
for (i = 0; i < len; i++) {
|
17
|
-
printf("%02X", (unsigned char)data[i]);
|
18
|
-
}
|
19
|
-
printf("\n");
|
20
|
-
}
|
16
|
+
VALUE cBlake2;
|
21
17
|
|
22
18
|
static void blake2_free(Blake2 *blake2) {
|
23
|
-
|
19
|
+
if(blake2->key_length > 0) {
|
20
|
+
ruby_xfree(blake2->key_bytes);
|
21
|
+
}
|
22
|
+
|
23
|
+
if(blake2->output_length > 0) {
|
24
|
+
ruby_xfree(blake2->output);
|
25
|
+
}
|
24
26
|
}
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
+
VALUE blake2_alloc(VALUE klass) {
|
29
|
+
VALUE blake2_obj = ruby_xmalloc(sizeof(Blake2));
|
30
|
+
|
31
|
+
return Data_Wrap_Struct(klass, NULL, blake2_free, blake2_obj);
|
28
32
|
}
|
29
33
|
|
30
34
|
VALUE m_blake2_initialize(VALUE self, VALUE _len, VALUE _key) {
|
31
|
-
|
32
|
-
|
35
|
+
Blake2 *blake2;
|
36
|
+
Data_Get_Struct(self, Blake2, blake2);
|
37
|
+
int i;
|
38
|
+
|
39
|
+
ID bytes_method = rb_intern("bytes");
|
40
|
+
blake2->to_hex = ID2SYM(rb_intern("to_hex"));
|
41
|
+
blake2->to_bytes = ID2SYM(rb_intern("to_bytes"));
|
33
42
|
|
34
|
-
|
35
|
-
|
36
|
-
|
43
|
+
VALUE key_bytes_ary = rb_funcall(_key, bytes_method, 0);
|
44
|
+
blake2->key_length = RARRAY_LEN(key_bytes_ary);
|
45
|
+
blake2->key_bytes = (uint8_t*)ruby_xmalloc(blake2->key_length * sizeof(uint8_t));
|
37
46
|
|
38
|
-
|
47
|
+
for(i = 0; i < blake2->key_length; i++) {
|
48
|
+
VALUE byte = rb_ary_entry(key_bytes_ary, i);
|
49
|
+
blake2->key_bytes[i] = NUM2INT(byte);
|
50
|
+
}
|
51
|
+
|
52
|
+
blake2->output_length = NUM2INT(_len);
|
53
|
+
blake2->output = (uint8_t*)ruby_xmalloc(blake2->output_length * sizeof(uint8_t));
|
54
|
+
|
55
|
+
return Qnil;
|
39
56
|
}
|
40
57
|
|
58
|
+
|
41
59
|
VALUE m_blake2_digest(VALUE self, VALUE _input, VALUE _representation) {
|
42
60
|
Blake2 *blake2;
|
43
61
|
|
44
|
-
|
45
|
-
VALUE to_bytes = ID2SYM(rb_intern("to_bytes"));
|
46
|
-
|
47
|
-
char * input = RSTRING_PTR(_input);
|
62
|
+
char * input = RSTRING_PTR(_input);
|
48
63
|
int input_length = RSTRING_LEN(_input);
|
49
64
|
int i;
|
50
65
|
|
51
66
|
Data_Get_Struct(self, Blake2, blake2);
|
52
67
|
|
53
|
-
|
54
|
-
|
55
|
-
int key_len = RARRAY_LEN(bytes_ary);
|
56
|
-
|
57
|
-
uint8_t * key_bytes = (uint8_t*)ruby_xmalloc(key_len * sizeof(uint8_t));
|
58
|
-
|
59
|
-
for(i = 0; i < key_len; i++) {
|
60
|
-
VALUE byte = rb_ary_entry(bytes_ary, i);
|
61
|
-
key_bytes[i] = NUM2INT(byte);
|
62
|
-
}
|
68
|
+
blake2s(blake2->output, input, blake2->key_bytes,
|
69
|
+
blake2->output_length, input_length, blake2->key_length);
|
63
70
|
|
64
|
-
|
65
|
-
blake2->output_length, input_length, key_len);
|
71
|
+
VALUE result;
|
66
72
|
|
67
|
-
if(_representation == to_bytes) {
|
68
|
-
|
73
|
+
if(_representation == blake2->to_bytes) {
|
74
|
+
result = rb_ary_new2(blake2->output_length);
|
69
75
|
|
70
76
|
for(i = 0; i < blake2->output_length; i++) {
|
71
77
|
rb_ary_push(result, INT2NUM(blake2->output[i]));
|
72
78
|
}
|
73
79
|
|
74
80
|
return result;
|
75
|
-
} else if(_representation == to_hex) {
|
81
|
+
} else if(_representation == blake2->to_hex) {
|
76
82
|
char * c_str = (char*)ruby_xmalloc(blake2->output_length * sizeof(char) * 2);
|
77
83
|
|
78
84
|
for(i = 0; i < blake2->output_length; i++) {
|
79
85
|
sprintf(c_str + (i * 2), "%02x", blake2->output[i]);
|
80
86
|
}
|
81
|
-
|
87
|
+
|
88
|
+
result = rb_str_new2(c_str);
|
89
|
+
|
90
|
+
ruby_xfree(c_str);
|
91
|
+
|
92
|
+
return result;
|
82
93
|
} else {
|
83
94
|
rb_raise(rb_eArgError, "Unknown representation", _representation);
|
84
95
|
}
|
85
96
|
}
|
97
|
+
|
86
98
|
void Init_blake2_ext() {
|
87
|
-
|
88
|
-
rb_define_alloc_func(
|
99
|
+
cBlake2 = rb_define_class("Blake2", rb_cObject);
|
100
|
+
rb_define_alloc_func(cBlake2, blake2_alloc);
|
89
101
|
|
90
|
-
rb_define_private_method(
|
91
|
-
rb_define_method(
|
102
|
+
rb_define_private_method(cBlake2, "initialize", RUBY_METHOD_FUNC(m_blake2_initialize), 2);
|
103
|
+
rb_define_method(cBlake2, "digest", RUBY_METHOD_FUNC(m_blake2_digest), 2);
|
92
104
|
}
|
data/lib/blake2/key.rb
CHANGED
@@ -9,15 +9,15 @@ class Blake2
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.from_string(str)
|
12
|
-
new(
|
12
|
+
new(str.bytes)
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.from_hex(hex_str)
|
16
|
-
new(
|
16
|
+
new([hex_str].pack("H*").bytes)
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.none
|
20
|
-
new(
|
20
|
+
new([])
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blake2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franck Verrot
|
@@ -12,25 +12,25 @@ cert_chain:
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIDaDCCAlCgAwIBAgIBATANBgkqhkiG9w0BAQUFADA9MQ8wDQYDVQQDDAZmcmFu
|
14
14
|
Y2sxFjAUBgoJkiaJk/IsZAEZFgZ2ZXJyb3QxEjAQBgoJkiaJk/IsZAEZFgJmcjAe
|
15
|
-
|
15
|
+
Fw0xNjA1MTMxOTQ3NTlaFw0xNzA1MTMxOTQ3NTlaMD0xDzANBgNVBAMMBmZyYW5j
|
16
16
|
azEWMBQGCgmSJomT8ixkARkWBnZlcnJvdDESMBAGCgmSJomT8ixkARkWAmZyMIIB
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
17
|
+
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA12mvBkBdLx5lIPvd0hJ6Ccer
|
18
|
+
t5fnF94UNRqE0zTxow9aAAtBb/G4fE/OkOBe69gq/5SSZRgF5m/qQ+//rZHSOUfR
|
19
|
+
f+a1Qqbho0CfFpAurAtDZQS45L5txhz1pRUnz/8bF6nkeKUF0pdLbNNVS9axE3uc
|
20
|
+
qBrfjUAP3yYe3K0TANgZym0TYJ3OhSeUV5Y8tuncuILHZI1hShYekjbPk3KLBJG5
|
21
|
+
16x3sHS209Y5LbRbzs85+HNBcNaN/Yi42IFl+mgdfyQLmbgSTpMtASPCXfsnAxsl
|
22
|
+
6QIiN9pQq9GSvCXA5wH+ZqYtFd6fJqDHVCDAlQ6lYBiCCpC/JV+lZj16c4yDnwID
|
23
|
+
AQABo3MwcTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU7Ygnr1Sx
|
24
|
+
42iryVPwtuJC/acw2TAwGwYDVR0RBBQwEoEQZnJhbmNrQHZlcnJvdC5mcjAbBgNV
|
25
|
+
HRIEFDASgRBmcmFuY2tAdmVycm90LmZyMA0GCSqGSIb3DQEBBQUAA4IBAQBdZVhZ
|
26
|
+
dhXujOsiysxAqtixFFXH9wSQNIltYQ8zuRLA/FgwqrNUQq+Qdiib5Kqj5hUK4okl
|
27
|
+
rTx4uCkHJszIocIZiKE/Ntk6xooQVTC/L95K/yycDCyss2c8JF2wdg/+q38u7rOS
|
28
|
+
fAbV2IGNLTPYWX+M2B08a6lVVRMD386TGrk0/ROjgZIhuHah4dY+ObAUyUv1oiyb
|
29
|
+
PEaDVSbqqbtwQAsY87Vam7GUcH/IJnhdLadvNOJlLr8jxW+gm1ZFE9MOlsSmHeGe
|
30
|
+
Z7BoH/Mfxw3P4yyir173p9JWvVqLiQE13XBeD13NPA8neoWpLJxm6k03PcTElT/E
|
31
|
+
QrOSgKrHAb/fFJma
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
33
|
+
date: 2016-05-13 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: rake-compiler
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.6.4
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: BLAKE2 - fast secure hashing - for Ruby
|
@@ -144,4 +144,3 @@ test_files:
|
|
144
144
|
- test/blake2/key_test.rb
|
145
145
|
- test/blake2_test.rb
|
146
146
|
- test/test_helper.rb
|
147
|
-
has_rdoc:
|
metadata.gz.sig
CHANGED
Binary file
|