guardtime 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/README.rdoc +8 -1
- data/ext/extconf.rb +2 -0
- data/ext/guardtime.c +32 -29
- metadata +3 -3
data/ChangeLog
CHANGED
data/README.rdoc
CHANGED
@@ -52,4 +52,11 @@ Verify:
|
|
52
52
|
r[:verification_errors] == GuardTime::NO_FAILURES
|
53
53
|
end
|
54
54
|
puts "data signed at #{signedAt.utc.to_s}" if okay
|
55
|
-
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
{<img src="https://travis-ci.org/ristik/ruby-guardtime.png?branch=master" alt="Build Status" />}[http://travis-ci.org/ristik/ruby-guardtime]
|
59
|
+
|
60
|
+
---
|
61
|
+
Published under Apache license v. 2.0.
|
62
|
+
Copyright GuardTime AS 2013
|
data/ext/extconf.rb
CHANGED
data/ext/guardtime.c
CHANGED
@@ -15,7 +15,11 @@
|
|
15
15
|
*/
|
16
16
|
|
17
17
|
#include "ruby.h"
|
18
|
-
#
|
18
|
+
#if RUBY_VERSION >= 190
|
19
|
+
# include <ruby/st.h>
|
20
|
+
#else
|
21
|
+
# include <st.h>
|
22
|
+
#endif
|
19
23
|
#include <time.h>
|
20
24
|
#include <gt_base.h>
|
21
25
|
#include <gt_http.h>
|
@@ -30,10 +34,10 @@ static VALUE rb_cGuardTime;
|
|
30
34
|
|
31
35
|
// object instance state
|
32
36
|
typedef struct _GuardTimeData {
|
33
|
-
char
|
34
|
-
char
|
35
|
-
char
|
36
|
-
char
|
37
|
+
const char* signeruri;
|
38
|
+
const char* verifieruri;
|
39
|
+
const char* pubfileuri;
|
40
|
+
const char* loadpubs;
|
37
41
|
time_t pubdataupdated;
|
38
42
|
GT_Time_t64 lastpublicationtime;
|
39
43
|
GTPublicationsFile *pub;
|
@@ -266,11 +270,11 @@ guardtime_sign(int argc, VALUE *argv, VALUE obj)
|
|
266
270
|
Data_Get_Struct(obj, GuardTimeData, gt);
|
267
271
|
res = GTHTTP_createTimestampHash(&dh, gt->signeruri, &ts);
|
268
272
|
if (res != GT_OK)
|
269
|
-
rb_raise(rb_eRuntimeError, GT_getErrorString(res));
|
273
|
+
rb_raise(rb_eRuntimeError, "%s", GT_getErrorString(res));
|
270
274
|
|
271
275
|
res = GTTimestamp_getDEREncoded(ts, &data, &data_length);
|
272
276
|
if (res != GT_OK)
|
273
|
-
rb_raise(rb_eRuntimeError, GT_getErrorString(res));
|
277
|
+
rb_raise(rb_eRuntimeError, "%s", GT_getErrorString(res));
|
274
278
|
GTTimestamp_free(ts);
|
275
279
|
result = rb_str_new((char*)data, data_length);
|
276
280
|
GT_free(data);
|
@@ -295,7 +299,6 @@ static VALUE
|
|
295
299
|
guardtime_extend(VALUE obj, VALUE in)
|
296
300
|
{
|
297
301
|
int res;
|
298
|
-
GTDataHash dh;
|
299
302
|
GTTimestamp *ts, *ts2;
|
300
303
|
unsigned char *data;
|
301
304
|
size_t data_length;
|
@@ -307,16 +310,16 @@ guardtime_extend(VALUE obj, VALUE in)
|
|
307
310
|
res = GTTimestamp_DERDecode(RSTRING_PTR(in),
|
308
311
|
RSTRING_LEN(in), &ts);
|
309
312
|
if (res != GT_OK)
|
310
|
-
rb_raise(rb_eRuntimeError, GT_getErrorString(res));
|
313
|
+
rb_raise(rb_eRuntimeError, "%s", GT_getErrorString(res));
|
311
314
|
|
312
315
|
res = GTHTTP_extendTimestamp(ts, gt->verifieruri, &ts2);
|
313
316
|
GTTimestamp_free(ts);
|
314
317
|
if (res != GT_OK)
|
315
|
-
rb_raise(rb_eRuntimeError, GT_getErrorString(res));
|
318
|
+
rb_raise(rb_eRuntimeError, "%s", GT_getErrorString(res));
|
316
319
|
|
317
320
|
res = GTTimestamp_getDEREncoded(ts2, &data, &data_length);
|
318
321
|
if (res != GT_OK)
|
319
|
-
rb_raise(rb_eRuntimeError, GT_getErrorString(res));
|
322
|
+
rb_raise(rb_eRuntimeError, "%s", GT_getErrorString(res));
|
320
323
|
|
321
324
|
result = rb_str_new((char*)data, data_length);
|
322
325
|
GT_free(data);
|
@@ -373,14 +376,14 @@ static void loadpubs(VALUE self)
|
|
373
376
|
rb_raise(rb_eRuntimeError, "Error downloading/validating publishing data: %s", GT_getErrorString(res));
|
374
377
|
}
|
375
378
|
|
376
|
-
static VALUE
|
377
|
-
|
379
|
+
static VALUE
|
380
|
+
gttime_to_rubyTime(GT_Time_t64 t)
|
378
381
|
{
|
379
|
-
VALUE
|
382
|
+
VALUE ruby_cTime, rubytime;
|
380
383
|
if (t == 0)
|
381
384
|
return Qnil;
|
382
|
-
|
383
|
-
rubytime = rb_funcall(
|
385
|
+
ruby_cTime = rb_const_get(rb_cObject, rb_intern("Time"));
|
386
|
+
rubytime = rb_funcall(ruby_cTime, rb_intern("at"), 1, ULL2NUM(t));
|
384
387
|
return rubytime;
|
385
388
|
}
|
386
389
|
|
@@ -484,6 +487,7 @@ guardtime_verify(int argc, VALUE *argv, VALUE obj)
|
|
484
487
|
GTDataHash dh;
|
485
488
|
GuardTimeData *gt;
|
486
489
|
VALUE tsdata, hash, hash2, block, retval;
|
490
|
+
GTVerificationInfo *verification_info = NULL;
|
487
491
|
Data_Get_Struct(obj, GuardTimeData, gt);
|
488
492
|
|
489
493
|
argcount = rb_scan_args(argc, argv, "12&", &tsdata, &hash, &hash2, &block);
|
@@ -492,10 +496,9 @@ guardtime_verify(int argc, VALUE *argv, VALUE obj)
|
|
492
496
|
res = GTTimestamp_DERDecode(RSTRING_PTR(tsdata),
|
493
497
|
RSTRING_LEN(tsdata), &ts);
|
494
498
|
if (res != GT_OK)
|
495
|
-
rb_raise(rb_eArgError, GT_getErrorString(res));
|
499
|
+
rb_raise(rb_eArgError, "%s", GT_getErrorString(res));
|
496
500
|
|
497
501
|
loadpubs(obj);
|
498
|
-
GTVerificationInfo *verification_info = NULL;
|
499
502
|
switch (argcount) {
|
500
503
|
case 1:
|
501
504
|
res = verifyTimestamp(ts, NULL, gt, RTEST(block)? 1:0, &verification_info);
|
@@ -512,7 +515,7 @@ guardtime_verify(int argc, VALUE *argv, VALUE obj)
|
|
512
515
|
|
513
516
|
if (res != GT_OK) {
|
514
517
|
GTTimestamp_free(ts);
|
515
|
-
rb_raise(rb_eRuntimeError, GT_getErrorString(res));
|
518
|
+
rb_raise(rb_eRuntimeError, "%s", GT_getErrorString(res));
|
516
519
|
}
|
517
520
|
|
518
521
|
#define RBNILSTR(n, i) \
|
@@ -545,8 +548,8 @@ guardtime_verify(int argc, VALUE *argv, VALUE obj)
|
|
545
548
|
} else
|
546
549
|
RBSET("pub_reference_list", Qnil);
|
547
550
|
|
548
|
-
RBSET("time",
|
549
|
-
RBSET("publication_time",
|
551
|
+
RBSET("time", gttime_to_rubyTime( verification_info->implicit_data->registered_time ));
|
552
|
+
RBSET("publication_time", gttime_to_rubyTime( verification_info->explicit_data->publication_identifier ));
|
550
553
|
} else
|
551
554
|
retval = verification_info->verification_errors == GT_NO_FAILURES ? Qtrue : Qfalse;
|
552
555
|
|
@@ -583,12 +586,12 @@ guardtime_getnewdigester(VALUE self, VALUE tsdata)
|
|
583
586
|
|
584
587
|
res = GTTimestamp_DERDecode(RSTRING_PTR(tsdata), RSTRING_LEN(tsdata), &ts);
|
585
588
|
if (res != GT_OK)
|
586
|
-
rb_raise(rb_eRuntimeError, GT_getErrorString(res));
|
589
|
+
rb_raise(rb_eRuntimeError, "%s", GT_getErrorString(res));
|
587
590
|
|
588
591
|
res = GTTimestamp_getAlgorithm(ts, &alg);
|
589
592
|
GTTimestamp_free(ts);
|
590
593
|
if (res != GT_OK)
|
591
|
-
rb_raise(rb_eRuntimeError, GT_getErrorString(res));
|
594
|
+
rb_raise(rb_eRuntimeError, "%s", GT_getErrorString(res));
|
592
595
|
|
593
596
|
// checkifnecessary: rb_requre('digest');
|
594
597
|
module_klass = rb_const_get(rb_cObject, rb_intern("Digest"));
|
@@ -617,7 +620,7 @@ guardtime_getnewdigester(VALUE self, VALUE tsdata)
|
|
617
620
|
return rb_class_new_instance(1, args,
|
618
621
|
rb_const_get(module_klass, rb_intern("SHA2")));
|
619
622
|
default:
|
620
|
-
rb_raise(rb_eRuntimeError, "Unknown hash algorithm ID");
|
623
|
+
rb_raise(rb_eRuntimeError, "%s", "Unknown hash algorithm ID");
|
621
624
|
}
|
622
625
|
return Qnil;
|
623
626
|
}
|
@@ -645,12 +648,12 @@ guardtime_gethashalg(VALUE self, VALUE tsdata)
|
|
645
648
|
|
646
649
|
res = GTTimestamp_DERDecode(RSTRING_PTR(tsdata), RSTRING_LEN(tsdata), &ts);
|
647
650
|
if (res != GT_OK)
|
648
|
-
rb_raise(rb_eRuntimeError, GT_getErrorString(res));
|
651
|
+
rb_raise(rb_eRuntimeError, "%s", GT_getErrorString(res));
|
649
652
|
|
650
653
|
res = GTTimestamp_getAlgorithm(ts, &alg);
|
651
654
|
GTTimestamp_free(ts);
|
652
655
|
if (res != GT_OK)
|
653
|
-
rb_raise(rb_eRuntimeError, GT_getErrorString(res));
|
656
|
+
rb_raise(rb_eRuntimeError, "%s", GT_getErrorString(res));
|
654
657
|
|
655
658
|
switch(alg) {
|
656
659
|
case GT_HASHALG_SHA256:
|
@@ -783,10 +786,10 @@ void Init_guardtime()
|
|
783
786
|
int res;
|
784
787
|
res = GT_init();
|
785
788
|
if (res != GT_OK)
|
786
|
-
rb_raise(rb_eRuntimeError, GT_getErrorString(res));
|
787
|
-
res = GTHTTP_init("ruby api 0.0.
|
789
|
+
rb_raise(rb_eRuntimeError, "%s", GT_getErrorString(res));
|
790
|
+
res = GTHTTP_init("ruby api 0.0.4", 1);
|
788
791
|
if (res != GT_OK)
|
789
|
-
rb_raise(rb_eRuntimeError, GT_getErrorString(res));
|
792
|
+
rb_raise(rb_eRuntimeError, "%s", GT_getErrorString(res));
|
790
793
|
|
791
794
|
rb_cGuardTime = rb_define_class("GuardTime", rb_cObject);
|
792
795
|
rb_define_alloc_func(rb_cGuardTime, guardtime_allocate);
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- GuardTime AS
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2013-01-
|
17
|
+
date: 2013-01-16 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|