digest-siphash 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c27f151cfd6e1509a0b7b8086b872f697faa1da9
4
+ data.tar.gz: 24c64c35d7be6a31e1099f272e79d638778f1e8f
5
+ SHA512:
6
+ metadata.gz: e073e6bdc4e2d985eb7ab22fb253d2460120bcda4fc71f4fd033ee52e473abf06f5ffbffe2e64b7aef9ea652e867815a468b9f9125f2068ef52125b77dd7f263
7
+ data.tar.gz: ade5bfd91c2b4403d7463f5d4d934e80d0e41a5abba1ca9fe5944797dd1ba7a3d28dd192c4e8f96c4ae86193c154c26380bdae4af0006f9076fce8991d6f257b
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ *.bundle
4
+ *.so
5
+ *.o
6
+ .bundle
7
+ .config
8
+ .yardoc
9
+ Gemfile.lock
10
+ InstalledFiles
11
+ _yardoc
12
+ coverage
13
+ doc/
14
+ lib/bundler/man
15
+ pkg
16
+ rdoc
17
+ spec/reports
18
+ test/tmp
19
+ test/version_tmp
20
+ tmp
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 ksss
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,53 @@
1
+ # Digest::SipHash
2
+
3
+ [![Build Status](https://travis-ci.org/ksss/digest-siphash.png)](https://travis-ci.org/ksss/digest-siphash)
4
+
5
+ Digest::SipHash is a class of message digest use algorithm SipHash.
6
+
7
+ ## Usage
8
+
9
+ ```ruby
10
+ require 'digest/siphash'
11
+
12
+ p Digest::SipHash.digest("siphash") #=> "\x59\xca\xae\xb9\x0d\x54\x24\x64"
13
+ p Digest::SipHash.hexdigest("siphash") #=> "59caaeb90d542464"
14
+ ```
15
+
16
+ you can change seed string(128bits).
17
+ seed default value is `SipHash::DEFAULT_SEED` ("\x00" * 16)
18
+
19
+ ```ruby
20
+ seed = (0..0x0f).to_a.pack("C16")
21
+ p Digest::SipHash.digest("siphash", seed) #=> "\x88\x27\x68\x57\x0d\xc7\x1c\x92"
22
+ p Digest::SipHash.hexdigest("siphash", seed) #=> "882768570dc71c92"
23
+ ```
24
+
25
+ and other way. instance use.
26
+
27
+ ```ruby
28
+ siphash = Digest::SipHash.new
29
+ siphash.update "siphash"
30
+ p siphash.digest #=> "\x88\x27\x68\x57\x0d\xc7\x1c\x92"
31
+
32
+ # of course, can change seed value.
33
+ siphash.seed = (0..0x0f).to_a.pack("C16")
34
+ p siphash.hexdigest "siphash" #=> "882768570dc71c92"
35
+ ```
36
+
37
+ ## Installation
38
+
39
+ Add this line to your application's Gemfile:
40
+
41
+ gem 'digest-siphash'
42
+
43
+ And then execute:
44
+
45
+ $ bundle
46
+
47
+ Or install it yourself as:
48
+
49
+ $ gem install digest-siphash
50
+
51
+ ## See also
52
+
53
+ [https://131002.net/siphash/](https://131002.net/siphash/)
@@ -0,0 +1,21 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec) do |t|
7
+ t.rspec_opts = ["-c", "-f progress", "-Ilib"]
8
+ t.pattern = "spec/**/*_spec.rb"
9
+ t.verbose = true
10
+ end
11
+ task :spec => :compile
12
+
13
+ require 'rake/extensiontask'
14
+ spec = Bundler::GemHelper.gemspec
15
+ Rake::ExtensionTask.new('siphash', spec) do |ext|
16
+ ext.ext_dir = 'ext/digest/siphash'
17
+ ext.lib_dir = 'lib/digest/siphash'
18
+ end
19
+
20
+
21
+ task :default => [:spec,:build]
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "digest-siphash"
7
+ spec.version = "0.0.1"
8
+ spec.authors = "ksss"
9
+ spec.email = "co000ri@gmail.com"
10
+ spec.summary = %q{Digest::SipHash is a class of message digest use algorithm SipHash.}
11
+ spec.description = %q{Digest::SipHash is a class of message digest use algorithm SipHash.}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+ spec.extensions = ["ext/digest/siphash/extconf.rb"]
20
+
21
+ spec.add_runtime_dependency "digest-stringbuffer", ["~> 0.0.2"]
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec", ['~> 2.11']
25
+ spec.add_development_dependency "rake-compiler", ["~> 0.8.3"]
26
+ end
@@ -0,0 +1,5 @@
1
+ require 'mkmf'
2
+
3
+ $preload = %w[digest]
4
+
5
+ create_makefile('digest/siphash/siphash')
@@ -0,0 +1,147 @@
1
+ #include "siphash24.h"
2
+ #include "siphash.h"
3
+
4
+ #define siphash crypto_auth
5
+ #define DEFAULT_SEED "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
6
+
7
+ VALUE cDigest_SipHash;
8
+ ID id_DEFAULT_SEED;
9
+ ID id_seed;
10
+
11
+ static VALUE
12
+ siphash_seed_get(VALUE self)
13
+ {
14
+ if (!rb_ivar_defined(self, id_seed)) {
15
+ rb_ivar_set(self, id_seed, rb_usascii_str_new(DEFAULT_SEED, 16));
16
+ }
17
+ return rb_ivar_get(self, id_seed);
18
+ }
19
+
20
+ static VALUE
21
+ siphash_seed_set(VALUE self, VALUE obj)
22
+ {
23
+ StringValue(obj);
24
+ if (RSTRING_LEN(obj) != 16) {
25
+ rb_raise(rb_eArgError, "seed string should 128 bit chars");
26
+ }
27
+ return rb_ivar_set(self, id_seed, obj);
28
+ }
29
+
30
+ static void
31
+ _siphash_s_digest(uint8_t* digest, int argc, VALUE *argv)
32
+ {
33
+ VALUE str;
34
+ const unsigned char *seed;
35
+
36
+ if (argc < 1)
37
+ rb_raise(rb_eArgError, "no data given");
38
+
39
+ str = argv[0];
40
+ StringValue(str);
41
+
42
+ if (1 < argc) {
43
+ StringValue(argv[1]);
44
+ if (RSTRING_LEN(argv[1]) != 16) {
45
+ rb_raise(rb_eArgError, "seed string should 128 bit chars");
46
+ }
47
+ seed = (const unsigned char*) RSTRING_PTR(argv[1]);
48
+ } else {
49
+ seed = (const unsigned char*) RSTRING_PTR(
50
+ rb_const_get(cDigest_SipHash, id_DEFAULT_SEED));
51
+ }
52
+
53
+ siphash(digest, (const unsigned char*) RSTRING_PTR(str), RSTRING_LEN(str), seed);
54
+ }
55
+
56
+ static inline void
57
+ _siphash_finish(uint8_t *digest, VALUE self)
58
+ {
59
+ const unsigned char *seed;
60
+ buffer_t *ptr;
61
+
62
+ Data_Get_Struct(self, buffer_t, ptr);
63
+ seed = (const unsigned char *) RSTRING_PTR(siphash_seed_get(self));
64
+ siphash(digest, (const unsigned char *) ptr->buffer, ptr->p - ptr->buffer, seed);
65
+ }
66
+
67
+ static VALUE
68
+ siphash_finish(VALUE self)
69
+ {
70
+ uint8_t digest[8];
71
+ #if LITTLE_ENDIAN
72
+ uint8_t roll[8];
73
+ int i;
74
+ #endif
75
+ _siphash_finish(digest, self);
76
+ #if LITTLE_ENDIAN
77
+ for (i = 0; i < 8; i++) {
78
+ roll[i] = digest[7 - i];
79
+ }
80
+ memcpy(digest, roll, 8);
81
+ #endif
82
+ return rb_str_new((const char*) digest, 8);
83
+ }
84
+
85
+ static VALUE
86
+ siphash_to_i(VALUE self)
87
+ {
88
+ uint8_t digest[8];
89
+ _siphash_finish(digest, self);
90
+ return ULL2NUM(*(uint64_t *) digest);
91
+ }
92
+
93
+ static VALUE
94
+ siphash_s_digest(int argc, VALUE *argv, VALUE klass)
95
+ {
96
+ uint8_t digest[8];
97
+ #if LITTLE_ENDIAN
98
+ uint8_t roll[8];
99
+ int i;
100
+ #endif
101
+ _siphash_s_digest(digest, argc, argv);
102
+ #if LITTLE_ENDIAN
103
+ for (i = 0; i < 8; i++) {
104
+ roll[i] = digest[7 - i];
105
+ }
106
+ memcpy(digest, roll, 8);
107
+ #endif
108
+ return rb_str_new((const char*) digest, 8);
109
+ }
110
+
111
+ static VALUE
112
+ siphash_s_hexdigest(int argc, VALUE *argv, VALUE klass)
113
+ {
114
+ return hexencode_str_new(siphash_s_digest(argc, argv, klass));
115
+ }
116
+
117
+ static VALUE
118
+ siphash_s_rawdigest(int argc, VALUE *argv, VALUE klass)
119
+ {
120
+ uint8_t digest[8];
121
+ _siphash_s_digest(digest, argc, argv);
122
+ return ULL2NUM(*(uint64_t *) digest);
123
+ }
124
+
125
+ void
126
+ Init_siphash(void)
127
+ {
128
+ VALUE mDigest, cDigest_StringBuffer;
129
+
130
+ id_DEFAULT_SEED = rb_intern("DEFAULT_SEED");
131
+ id_seed = rb_intern("seed");
132
+
133
+ /* Digest::SipHash is require that Digest::StringBuffer */
134
+ mDigest = rb_path2class("Digest");
135
+ cDigest_StringBuffer = rb_path2class("Digest::StringBuffer");
136
+
137
+ /* class Digest::SipHash < Digest::StringBuffer */
138
+ cDigest_SipHash = rb_define_class_under(mDigest, "SipHash", cDigest_StringBuffer);
139
+ rb_define_private_method(cDigest_SipHash, "finish", siphash_finish, 0);
140
+ rb_define_method(cDigest_SipHash, "to_i", siphash_to_i, 0);
141
+ rb_define_method(cDigest_SipHash, "seed", siphash_seed_get, 0);
142
+ rb_define_method(cDigest_SipHash, "seed=", siphash_seed_set, 1);
143
+ rb_define_const(cDigest_SipHash, "DEFAULT_SEED", rb_usascii_str_new(DEFAULT_SEED, 16));
144
+ rb_define_singleton_method(cDigest_SipHash, "digest", siphash_s_digest, -1);
145
+ rb_define_singleton_method(cDigest_SipHash, "hexdigest", siphash_s_hexdigest, -1);
146
+ rb_define_singleton_method(cDigest_SipHash, "rawdigest", siphash_s_rawdigest, -1);
147
+ }
@@ -0,0 +1,68 @@
1
+ #ifndef SIPHASH_INCLUDED
2
+ # define SIPHASH_INCLUDED
3
+
4
+ #include "ruby.h"
5
+
6
+ #ifndef LITTLE_ENDIAN
7
+ /* NO-OP for little-endian platforms */
8
+ # if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
9
+ # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
10
+ # define LITTLE_ENDIAN 1
11
+ # endif
12
+ /* if __BYTE_ORDER__ is not predefined (like FreeBSD), use arch */
13
+ # elif defined(__i386) || defined(__x86_64) || defined(__alpha) || defined(__vax)
14
+ # define LITTLE_ENDIAN 1
15
+ # endif
16
+ #endif
17
+
18
+ /* last resort (big-endian w/o __builtin_bswap64) */
19
+ #ifndef LITTLE_ENDIAN
20
+ # define LITTLE_ENDIAN 0
21
+ #endif
22
+
23
+ /* should be same type structure to digest/stringbuffer */
24
+ typedef struct {
25
+ char* buffer;
26
+ char* p;
27
+ size_t memsize;
28
+ } buffer_t;
29
+
30
+ /*
31
+ * from https://github.com/ruby/ruby/blob/trunk/ext/digest/digest.c
32
+ * Copyright (C) 1995-2001 Yukihiro Matsumoto
33
+ * Copyright (C) 2001-2006 Akinori MUSHA
34
+ */
35
+ static VALUE
36
+ hexencode_str_new(VALUE str_digest)
37
+ {
38
+ char *digest;
39
+ size_t digest_len;
40
+ size_t i;
41
+ VALUE str;
42
+ char *p;
43
+ static const char hex[] = {
44
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
45
+ 'a', 'b', 'c', 'd', 'e', 'f'
46
+ };
47
+
48
+ StringValue(str_digest);
49
+ digest = RSTRING_PTR(str_digest);
50
+ digest_len = RSTRING_LEN(str_digest);
51
+
52
+ if (LONG_MAX / 2 < digest_len) {
53
+ rb_raise(rb_eRuntimeError, "digest string too long");
54
+ }
55
+
56
+ str = rb_usascii_str_new(0, digest_len * 2);
57
+
58
+ for (i = 0, p = RSTRING_PTR(str); i < digest_len; i++) {
59
+ unsigned char byte = digest[i];
60
+
61
+ p[i + i] = hex[byte >> 4];
62
+ p[i + i + 1] = hex[byte & 0x0f];
63
+ }
64
+
65
+ return str;
66
+ }
67
+
68
+ #endif /* ifndef SIPHASH_INCLUDED */
@@ -0,0 +1,103 @@
1
+ /*
2
+ SipHash reference C implementation
3
+
4
+ Written in 2012 by
5
+ Jean-Philippe Aumasson <jeanphilippe.aumasson@gmail.com>
6
+ Daniel J. Bernstein <djb@cr.yp.to>
7
+
8
+ To the extent possible under law, the author(s) have dedicated all copyright
9
+ and related and neighboring rights to this software to the public domain
10
+ worldwide. This software is distributed without any warranty.
11
+
12
+ You should have received a copy of the CC0 Public Domain Dedication along with
13
+ this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
14
+ */
15
+ #include <stdint.h>
16
+ #include <stdio.h>
17
+ #include <string.h>
18
+ typedef uint64_t u64;
19
+ typedef uint32_t u32;
20
+ typedef uint8_t u8;
21
+
22
+ #define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
23
+
24
+ #define U32TO8_LE(p, v) \
25
+ (p)[0] = (u8)((v) ); (p)[1] = (u8)((v) >> 8); \
26
+ (p)[2] = (u8)((v) >> 16); (p)[3] = (u8)((v) >> 24);
27
+
28
+ #define U64TO8_LE(p, v) \
29
+ U32TO8_LE((p), (u32)((v) )); \
30
+ U32TO8_LE((p) + 4, (u32)((v) >> 32));
31
+
32
+ #define U8TO64_LE(p) \
33
+ (((u64)((p)[0]) ) | \
34
+ ((u64)((p)[1]) << 8) | \
35
+ ((u64)((p)[2]) << 16) | \
36
+ ((u64)((p)[3]) << 24) | \
37
+ ((u64)((p)[4]) << 32) | \
38
+ ((u64)((p)[5]) << 40) | \
39
+ ((u64)((p)[6]) << 48) | \
40
+ ((u64)((p)[7]) << 56))
41
+
42
+ #define SIPROUND \
43
+ do { \
44
+ v0 += v1; v1=ROTL(v1,13); v1 ^= v0; v0=ROTL(v0,32); \
45
+ v2 += v3; v3=ROTL(v3,16); v3 ^= v2; \
46
+ v0 += v3; v3=ROTL(v3,21); v3 ^= v0; \
47
+ v2 += v1; v1=ROTL(v1,17); v1 ^= v2; v2=ROTL(v2,32); \
48
+ } while(0)
49
+
50
+ /* SipHash-2-4 */
51
+ int crypto_auth( unsigned char *out, const unsigned char *in, unsigned long long inlen, const unsigned char *k )
52
+ {
53
+ /* "somepseudorandomlygeneratedbytes" */
54
+ u64 v0 = 0x736f6d6570736575ULL;
55
+ u64 v1 = 0x646f72616e646f6dULL;
56
+ u64 v2 = 0x6c7967656e657261ULL;
57
+ u64 v3 = 0x7465646279746573ULL;
58
+ u64 b;
59
+ u64 k0 = U8TO64_LE( k );
60
+ u64 k1 = U8TO64_LE( k + 8 );
61
+ u64 m;
62
+ const u8 *end = in + inlen - ( inlen % sizeof( u64 ) );
63
+ const int left = inlen & 7;
64
+ b = ( ( u64 )inlen ) << 56;
65
+ v3 ^= k1;
66
+ v2 ^= k0;
67
+ v1 ^= k1;
68
+ v0 ^= k0;
69
+
70
+ for ( ; in != end; in += 8 )
71
+ {
72
+ m = U8TO64_LE( in );
73
+ v3 ^= m;
74
+ SIPROUND;
75
+ SIPROUND;
76
+ v0 ^= m;
77
+ }
78
+
79
+ switch( left )
80
+ {
81
+ case 7: b |= ( ( u64 )in[ 6] ) << 48;
82
+ case 6: b |= ( ( u64 )in[ 5] ) << 40;
83
+ case 5: b |= ( ( u64 )in[ 4] ) << 32;
84
+ case 4: b |= ( ( u64 )in[ 3] ) << 24;
85
+ case 3: b |= ( ( u64 )in[ 2] ) << 16;
86
+ case 2: b |= ( ( u64 )in[ 1] ) << 8;
87
+ case 1: b |= ( ( u64 )in[ 0] ); break;
88
+ case 0: break;
89
+ }
90
+
91
+ v3 ^= b;
92
+ SIPROUND;
93
+ SIPROUND;
94
+ v0 ^= b;
95
+ v2 ^= 0xff;
96
+ SIPROUND;
97
+ SIPROUND;
98
+ SIPROUND;
99
+ SIPROUND;
100
+ b = v0 ^ v1 ^ v2 ^ v3;
101
+ U64TO8_LE( out, b );
102
+ return 0;
103
+ }
@@ -0,0 +1,6 @@
1
+ require "digest/stringbuffer"
2
+ begin
3
+ require "digest/siphash/#{RUBY_VERSION[/\d+.\d+/]}/siphash"
4
+ rescue LoadError
5
+ require "digest/siphash/siphash"
6
+ end
@@ -0,0 +1,60 @@
1
+ # coding: ascii-8bit
2
+ require 'spec_helper'
3
+
4
+ describe Digest::SipHash do
5
+ let :seed do
6
+ (0..0x0f).to_a.pack("C16")
7
+ end
8
+
9
+ it "initialize" do
10
+ expect(SipHash.new).to be_a_kind_of(StringBuffer)
11
+ end
12
+
13
+ it "DEFAULT_SEED" do
14
+ expect(SipHash::DEFAULT_SEED).to eq("\x00" * 16)
15
+ end
16
+
17
+ it "seed" do
18
+ sip = SipHash.new
19
+ expect(sip.seed).to eq("\x00" * 16)
20
+ end
21
+
22
+ it "seed=" do
23
+ sip = SipHash.new
24
+ sip.seed = seed
25
+ expect(sip.seed).to eq(seed)
26
+ end
27
+
28
+ it "digest" do
29
+ expect(SipHash.digest("")).to eq("\x1e\x92\x4b\x9d\x73\x77\x00\xd7")
30
+ expect(SipHash.digest("", seed)).to eq("\x72\x6f\xdb\x47\xdd\x0e\x0e\x31")
31
+ expect(SipHash.digest("\x00", seed)).to eq("\x74\xf8\x39\xc5\x93\xdc\x67\xfd")
32
+ expect(SipHash.digest("\x00\x01", seed)).to eq("\x0d\x6c\x80\x09\xd9\xa9\x4f\x5a")
33
+ end
34
+
35
+ it "hexdigest" do
36
+ expect(SipHash.hexdigest("")).to eq("1e924b9d737700d7")
37
+ expect(SipHash.hexdigest("", seed)).to eq("726fdb47dd0e0e31")
38
+ expect(SipHash.hexdigest("\x00", seed)).to eq("74f839c593dc67fd")
39
+ expect(SipHash.hexdigest("\x00\x01", seed)).to eq("0d6c8009d9a94f5a")
40
+ end
41
+
42
+ it "rawdigest" do
43
+ expect(SipHash.rawdigest("")).to eq(0x1e924b9d737700d7)
44
+ expect(SipHash.rawdigest("", seed)).to eq(0x726fdb47dd0e0e31)
45
+ expect(SipHash.rawdigest("\x00", seed)).to eq(0x74f839c593dc67fd)
46
+ expect(SipHash.rawdigest("\x00\x01", seed)).to eq(0x0d6c8009d9a94f5a)
47
+ end
48
+
49
+ it "instance digest" do
50
+ sip = SipHash.new
51
+ sip.update ""
52
+ expect(sip.digest).to eq("\x1e\x92\x4b\x9d\x73\x77\x00\xd7")
53
+ expect(sip.to_i).to eq(0x1e924b9d737700d7)
54
+
55
+ sip.seed = seed
56
+ expect(sip.digest).to eq("\x72\x6f\xdb\x47\xdd\x0e\x0e\x31")
57
+ expect(sip.to_i).to eq(0x726fdb47dd0e0e31)
58
+ end
59
+ end
60
+
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Digest::SipHash do
4
+ it "no data given" do
5
+ expect{ SipHash::digest }.to raise_error(ArgumentError)
6
+ end
7
+
8
+ it "seed string should 128 bit chars" do
9
+ expect{ SipHash::digest("siphash", "\x00") }.to raise_error(ArgumentError)
10
+
11
+ sip = SipHash.new
12
+ expect{ sip.seed = "0x00" }.to raise_error(ArgumentError)
13
+ end
14
+ end
15
+
16
+
17
+
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Digest::SipHash do
4
+ it "gc safe" do
5
+ sip = SipHash.new
6
+ GC.start
7
+ sip.update "siphash"
8
+ GC.start
9
+ expect(sip.hexdigest).to eq("59caaeb90d542464")
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ require 'digest/siphash'
2
+ include Digest
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: digest-siphash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - ksss
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: digest-stringbuffer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.11'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.11'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake-compiler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.8.3
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 0.8.3
83
+ description: Digest::SipHash is a class of message digest use algorithm SipHash.
84
+ email: co000ri@gmail.com
85
+ executables: []
86
+ extensions:
87
+ - ext/digest/siphash/extconf.rb
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .travis.yml
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - digest-siphash.gemspec
97
+ - ext/digest/siphash/extconf.rb
98
+ - ext/digest/siphash/init.c
99
+ - ext/digest/siphash/siphash.h
100
+ - ext/digest/siphash/siphash24.h
101
+ - lib/digest/siphash.rb
102
+ - spec/digest_spec.rb
103
+ - spec/exception_spec.rb
104
+ - spec/mem_spec.rb
105
+ - spec/spec_helper.rb
106
+ homepage: ''
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.1.11
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Digest::SipHash is a class of message digest use algorithm SipHash.
130
+ test_files:
131
+ - spec/digest_spec.rb
132
+ - spec/exception_spec.rb
133
+ - spec/mem_spec.rb
134
+ - spec/spec_helper.rb