xmldsign 0.1.5 → 0.1.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 +15 -0
- data/ext/xmldsign/gost89.c +13 -1
- data/ext/xmldsign/gosthash.c +30 -29
- data/lib/xmldsign/version.rb +1 -1
- metadata +29 -51
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MTljM2IyNjczYTFjODk0MmI0MWM0NjBkZTc0YjYwMDRiZTFlZTA2Nw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MDM2MWIzMzdmNzZhMGY4ZDM4NWU5NmQ4ZDE1MGExMDNiZmU5N2ZkNA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YTNiZTg3YjdkZDE2ZWI4NDk0M2E5Yjc5MzI0MDEwZGM2NWU1Mjc0YTljOTU3
|
10
|
+
OGE3MmQxZjBiMzc2YzkyNTdkNzg2MmI2YzI5MmIwY2Q0MDgwZmRhZDI5N2Nl
|
11
|
+
MGYwYjgwZGJlYTg1ZTU5MjM5ODhlNmZhNmNlNDQ3MGU1MTM2MWY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MjdlNjAyNDdhNGM5NmI4ZWFhNWFmODlmOTA4YjE1YjM5NzAzMjM3ZWVmYWFk
|
14
|
+
ZDVhOTRhNmI5NTFkYmZiNDg2MDk3YzhkNmMyMTc1NzI1NGI3NDA2MTFmZjQw
|
15
|
+
ZjhjNDc3YjM0MmEzZWUyNjk4NWZlYmU0MzY1NGY4MGMwMzY4Mjg=
|
data/ext/xmldsign/gost89.c
CHANGED
@@ -369,7 +369,13 @@ int gost_mac(gost_ctx *ctx,int mac_len,const unsigned char *data,
|
|
369
369
|
memset(buf2,0,8);
|
370
370
|
memcpy(buf2,data+i,data_len-i);
|
371
371
|
mac_block(ctx,buffer,buf2);
|
372
|
-
|
372
|
+
i+=8;
|
373
|
+
}
|
374
|
+
if (i==8)
|
375
|
+
{
|
376
|
+
memset(buf2,0,8);
|
377
|
+
mac_block(ctx,buffer,buf2);
|
378
|
+
}
|
373
379
|
get_mac(buffer,mac_len,mac);
|
374
380
|
return 1;
|
375
381
|
}
|
@@ -389,7 +395,13 @@ int gost_mac_iv(gost_ctx *ctx,int mac_len,const unsigned char *iv,const unsigned
|
|
389
395
|
memset(buf2,0,8);
|
390
396
|
memcpy(buf2,data+i,data_len-i);
|
391
397
|
mac_block(ctx,buffer,buf2);
|
398
|
+
i+=8;
|
392
399
|
}
|
400
|
+
if (i==8)
|
401
|
+
{
|
402
|
+
memset(buf2,0,8);
|
403
|
+
mac_block(ctx,buffer,buf2);
|
404
|
+
}
|
393
405
|
get_mac(buffer,mac_len,mac);
|
394
406
|
return 1;
|
395
407
|
}
|
data/ext/xmldsign/gosthash.c
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
#include "gosthash.h"
|
13
13
|
|
14
14
|
|
15
|
-
/* Use OPENSSL_malloc for memory allocation if compiled with
|
15
|
+
/* Use OPENSSL_malloc for memory allocation if compiled with
|
16
16
|
* -DOPENSSL_BUILD, and libc malloc otherwise
|
17
17
|
*/
|
18
18
|
#ifndef MYALLOC
|
@@ -27,27 +27,28 @@
|
|
27
27
|
#endif
|
28
28
|
/* Following functions are various bit meshing routines used in
|
29
29
|
* GOST R 34.11-94 algorithms */
|
30
|
-
static void swap_bytes (byte *w, byte *k)
|
30
|
+
static void swap_bytes (byte *w, byte *k)
|
31
31
|
{
|
32
32
|
int i,j;
|
33
|
-
for (i=0;i<4;i++)
|
34
|
-
for (j=0;j<8;j++)
|
33
|
+
for (i=0;i<4;i++)
|
34
|
+
for (j=0;j<8;j++)
|
35
35
|
k[i+4*j]=w[8*i+j];
|
36
|
+
|
36
37
|
}
|
37
38
|
|
38
39
|
/* was A_A */
|
39
|
-
static void circle_xor8 (const byte *w, byte *k)
|
40
|
+
static void circle_xor8 (const byte *w, byte *k)
|
40
41
|
{
|
41
42
|
byte buf[8];
|
42
43
|
int i;
|
43
44
|
memcpy(buf,w,8);
|
44
|
-
|
45
|
+
memmove(k,w+8,24);
|
45
46
|
for(i=0;i<8;i++)
|
46
47
|
k[i+24]=buf[i]^k[i];
|
47
48
|
}
|
48
49
|
|
49
50
|
/* was R_R */
|
50
|
-
static void transform_3 (byte *data)
|
51
|
+
static void transform_3 (byte *data)
|
51
52
|
{
|
52
53
|
unsigned short int acc;
|
53
54
|
acc=(data[0]^data[2]^data[4]^data[6]^data[24]^data[30])|
|
@@ -58,32 +59,32 @@ static void transform_3 (byte *data)
|
|
58
59
|
}
|
59
60
|
|
60
61
|
/* Adds blocks of N bytes modulo 2**(8*n). Returns carry*/
|
61
|
-
static int add_blocks(int n,byte *left, const byte *right)
|
62
|
+
static int add_blocks(int n,byte *left, const byte *right)
|
62
63
|
{
|
63
64
|
int i;
|
64
65
|
int carry=0;
|
65
66
|
int sum;
|
66
|
-
for (i=0;i<n;i++)
|
67
|
+
for (i=0;i<n;i++)
|
67
68
|
{
|
68
69
|
sum=(int)left[i]+(int)right[i]+carry;
|
69
70
|
left[i]=sum & 0xff;
|
70
71
|
carry=sum>>8;
|
71
72
|
}
|
72
73
|
return carry;
|
73
|
-
}
|
74
|
+
}
|
74
75
|
|
75
76
|
/* Xor two sequences of bytes */
|
76
77
|
static void xor_blocks (byte *result,const byte *a,const byte *b,size_t len)
|
77
78
|
{
|
78
79
|
size_t i;
|
79
80
|
for (i=0;i<len;i++) result[i]=a[i]^b[i];
|
80
|
-
}
|
81
|
+
}
|
81
82
|
|
82
|
-
/*
|
83
|
-
* Calculate H(i+1) = Hash(Hi,Mi)
|
83
|
+
/*
|
84
|
+
* Calculate H(i+1) = Hash(Hi,Mi)
|
84
85
|
* Where H and M are 32 bytes long
|
85
86
|
*/
|
86
|
-
static int hash_step(gost_ctx *c,byte *H,const byte *M)
|
87
|
+
static int hash_step(gost_ctx *c,byte *H,const byte *M)
|
87
88
|
{
|
88
89
|
byte U[32],W[32],V[32],S[32],Key[32];
|
89
90
|
int i;
|
@@ -120,12 +121,12 @@ static int hash_step(gost_ctx *c,byte *H,const byte *M)
|
|
120
121
|
swap_bytes(W,Key);
|
121
122
|
/* Encrypt last 8 bytes with fourth key */
|
122
123
|
gost_enc_with_key(c,Key,H+24,S+24);
|
123
|
-
for (i=0;i<12;i++)
|
124
|
+
for (i=0;i<12;i++)
|
124
125
|
transform_3(S);
|
125
126
|
xor_blocks(S,S,M,32);
|
126
127
|
transform_3(S);
|
127
128
|
xor_blocks(S,S,H,32);
|
128
|
-
for (i=0;i<61;i++)
|
129
|
+
for (i=0;i<61;i++)
|
129
130
|
transform_3(S);
|
130
131
|
memcpy(H,S,32);
|
131
132
|
return 1;
|
@@ -135,13 +136,13 @@ static int hash_step(gost_ctx *c,byte *H,const byte *M)
|
|
135
136
|
* set up substitution blocks
|
136
137
|
*/
|
137
138
|
int init_gost_hash_ctx(gost_hash_ctx *ctx, const gost_subst_block *subst_block)
|
138
|
-
{
|
139
|
+
{
|
139
140
|
memset(ctx,0,sizeof(gost_hash_ctx));
|
140
141
|
ctx->cipher_ctx = (gost_ctx *)MYALLOC(sizeof(gost_ctx));
|
141
142
|
if (!ctx->cipher_ctx)
|
142
143
|
{
|
143
144
|
return 0;
|
144
|
-
}
|
145
|
+
}
|
145
146
|
gost_init(ctx->cipher_ctx,subst_block);
|
146
147
|
return 1;
|
147
148
|
}
|
@@ -151,8 +152,8 @@ int init_gost_hash_ctx(gost_hash_ctx *ctx, const gost_subst_block *subst_block)
|
|
151
152
|
* if cipher ctx is statically allocated as in OpenSSL implementation of
|
152
153
|
* GOST hash algroritm
|
153
154
|
*
|
154
|
-
*/
|
155
|
-
void done_gost_hash_ctx(gost_hash_ctx *ctx)
|
155
|
+
*/
|
156
|
+
void done_gost_hash_ctx(gost_hash_ctx *ctx)
|
156
157
|
{
|
157
158
|
/* No need to use gost_destroy, because cipher keys are not really
|
158
159
|
* secret when hashing */
|
@@ -188,13 +189,13 @@ int hash_block(gost_hash_ctx *ctx,const byte *block, size_t length)
|
|
188
189
|
if (add_bytes>length)
|
189
190
|
{
|
190
191
|
add_bytes = length;
|
191
|
-
}
|
192
|
+
}
|
192
193
|
memcpy(&(ctx->remainder[ctx->left]),block,add_bytes);
|
193
194
|
ctx->left+=add_bytes;
|
194
195
|
if (ctx->left<32)
|
195
196
|
{
|
196
197
|
return 1;
|
197
|
-
}
|
198
|
+
}
|
198
199
|
curptr=block+add_bytes;
|
199
200
|
hash_step(ctx->cipher_ctx,ctx->H,ctx->remainder);
|
200
201
|
add_blocks(32,ctx->S,ctx->remainder);
|
@@ -202,26 +203,26 @@ int hash_block(gost_hash_ctx *ctx,const byte *block, size_t length)
|
|
202
203
|
ctx->left=0;
|
203
204
|
}
|
204
205
|
while (curptr<=barrier)
|
205
|
-
{
|
206
|
+
{
|
206
207
|
hash_step(ctx->cipher_ctx,ctx->H,curptr);
|
207
|
-
|
208
|
+
|
208
209
|
add_blocks(32,ctx->S,curptr);
|
209
210
|
ctx->len+=32;
|
210
211
|
curptr+=32;
|
211
|
-
}
|
212
|
+
}
|
212
213
|
if (curptr!=block+length)
|
213
214
|
{
|
214
215
|
ctx->left=block+length-curptr;
|
215
216
|
memcpy(ctx->remainder,curptr,ctx->left);
|
216
|
-
}
|
217
|
-
return 1;
|
217
|
+
}
|
218
|
+
return 1;
|
218
219
|
}
|
219
220
|
|
220
221
|
/*
|
221
222
|
* Compute hash value from current state of ctx
|
222
223
|
* state of hash ctx becomes invalid and cannot be used for further
|
223
224
|
* hashing.
|
224
|
-
*/
|
225
|
+
*/
|
225
226
|
int finish_hash(gost_hash_ctx *ctx,byte *hashval)
|
226
227
|
{
|
227
228
|
byte buf[32];
|
@@ -230,7 +231,7 @@ int finish_hash(gost_hash_ctx *ctx,byte *hashval)
|
|
230
231
|
ghosthash_len fin_len=ctx->len;
|
231
232
|
byte *bptr;
|
232
233
|
memcpy(H,ctx->H,32);
|
233
|
-
|
234
|
+
memcpy(S,ctx->S,32);
|
234
235
|
if (ctx->left)
|
235
236
|
{
|
236
237
|
memset(buf,0,32);
|
data/lib/xmldsign/version.rb
CHANGED
metadata
CHANGED
@@ -1,128 +1,113 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xmldsign
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Anton Sozontov
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-04-11 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
prerelease: false
|
15
15
|
name: libxml-ruby
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ! '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
16
21
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
22
|
requirements:
|
19
23
|
- - ! '>='
|
20
24
|
- !ruby/object:Gem::Version
|
21
25
|
version: '0'
|
22
26
|
type: :runtime
|
27
|
+
- !ruby/object:Gem::Dependency
|
23
28
|
prerelease: false
|
29
|
+
name: libxslt-ruby
|
24
30
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
31
|
requirements:
|
27
32
|
- - ! '>='
|
28
33
|
- !ruby/object:Gem::Version
|
29
34
|
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: libxslt-ruby
|
32
35
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
36
|
requirements:
|
35
37
|
- - ! '>='
|
36
38
|
- !ruby/object:Gem::Version
|
37
39
|
version: '0'
|
38
40
|
type: :runtime
|
41
|
+
- !ruby/object:Gem::Dependency
|
39
42
|
prerelease: false
|
43
|
+
name: rake-compiler
|
40
44
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
45
|
requirements:
|
43
|
-
- -
|
46
|
+
- - ~>
|
44
47
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rake-compiler
|
48
|
+
version: 0.7.7
|
48
49
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: 0.7.7
|
54
54
|
type: :development
|
55
|
+
- !ruby/object:Gem::Dependency
|
55
56
|
prerelease: false
|
57
|
+
name: rake
|
56
58
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
59
|
requirements:
|
59
|
-
- -
|
60
|
+
- - '='
|
60
61
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rake
|
62
|
+
version: 0.8.7
|
64
63
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
64
|
requirements:
|
67
65
|
- - '='
|
68
66
|
- !ruby/object:Gem::Version
|
69
67
|
version: 0.8.7
|
70
68
|
type: :development
|
69
|
+
- !ruby/object:Gem::Dependency
|
71
70
|
prerelease: false
|
71
|
+
name: rspec
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
73
|
requirements:
|
75
|
-
- - '
|
74
|
+
- - ! '>='
|
76
75
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: rspec
|
76
|
+
version: '0'
|
80
77
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
78
|
requirements:
|
83
79
|
- - ! '>='
|
84
80
|
- !ruby/object:Gem::Version
|
85
81
|
version: '0'
|
86
82
|
type: :development
|
83
|
+
- !ruby/object:Gem::Dependency
|
87
84
|
prerelease: false
|
85
|
+
name: pry
|
88
86
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
87
|
requirements:
|
91
88
|
- - ! '>='
|
92
89
|
- !ruby/object:Gem::Version
|
93
90
|
version: '0'
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: pry
|
96
91
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
92
|
requirements:
|
99
93
|
- - ! '>='
|
100
94
|
- !ruby/object:Gem::Version
|
101
95
|
version: '0'
|
102
96
|
type: :development
|
97
|
+
- !ruby/object:Gem::Dependency
|
103
98
|
prerelease: false
|
99
|
+
name: pry-debugger
|
104
100
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
101
|
requirements:
|
107
102
|
- - ! '>='
|
108
103
|
- !ruby/object:Gem::Version
|
109
104
|
version: '0'
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: pry-debugger
|
112
105
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
106
|
requirements:
|
115
107
|
- - ! '>='
|
116
108
|
- !ruby/object:Gem::Version
|
117
109
|
version: '0'
|
118
110
|
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ! '>='
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '0'
|
126
111
|
description: Xmldsign library for ruby with GOST algorithms
|
127
112
|
email:
|
128
113
|
- a.sozontov@gmail.com
|
@@ -194,33 +179,26 @@ files:
|
|
194
179
|
- xmldsign.gemspec
|
195
180
|
homepage: ''
|
196
181
|
licenses: []
|
182
|
+
metadata: {}
|
197
183
|
post_install_message:
|
198
184
|
rdoc_options: []
|
199
185
|
require_paths:
|
200
186
|
- lib
|
201
187
|
required_ruby_version: !ruby/object:Gem::Requirement
|
202
|
-
none: false
|
203
188
|
requirements:
|
204
189
|
- - ! '>='
|
205
190
|
- !ruby/object:Gem::Version
|
206
191
|
version: '0'
|
207
|
-
segments:
|
208
|
-
- 0
|
209
|
-
hash: 1771735899723035723
|
210
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
211
|
-
none: false
|
212
193
|
requirements:
|
213
194
|
- - ! '>='
|
214
195
|
- !ruby/object:Gem::Version
|
215
196
|
version: '0'
|
216
|
-
segments:
|
217
|
-
- 0
|
218
|
-
hash: 1771735899723035723
|
219
197
|
requirements: []
|
220
198
|
rubyforge_project:
|
221
|
-
rubygems_version:
|
199
|
+
rubygems_version: 2.0.3
|
222
200
|
signing_key:
|
223
|
-
specification_version:
|
201
|
+
specification_version: 4
|
224
202
|
summary: Xmldsign library for ruby with GOST algorithms. Work in progress...
|
225
203
|
test_files:
|
226
204
|
- spec/assets/act-birth-for-sign.xml
|