digest 3.2.1 → 3.3.0
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 +4 -4
- data/README.md +4 -1
- data/ext/digest/blake3/LICENSE_A2 +202 -0
- data/ext/digest/blake3/LICENSE_A2LLVM +219 -0
- data/ext/digest/blake3/LICENSE_CC0 +121 -0
- data/ext/digest/blake3/blake3.c +651 -0
- data/ext/digest/blake3/blake3.h +86 -0
- data/ext/digest/blake3/blake3_avx2.c +326 -0
- data/ext/digest/blake3/blake3_avx512.c +1388 -0
- data/ext/digest/blake3/blake3_dispatch.c +333 -0
- data/ext/digest/blake3/blake3_impl.h +333 -0
- data/ext/digest/blake3/blake3_neon.c +367 -0
- data/ext/digest/blake3/blake3_portable.c +160 -0
- data/ext/digest/blake3/blake3_sse2.c +566 -0
- data/ext/digest/blake3/blake3_sse41.c +560 -0
- data/ext/digest/blake3/blake3init.c +93 -0
- data/ext/digest/blake3/extconf.rb +102 -0
- data/ext/digest/bubblebabble/depend +4 -0
- data/ext/digest/crc32/crc32.c +66 -0
- data/ext/digest/crc32/crc32.h +26 -0
- data/ext/digest/crc32/crc32init.c +54 -0
- data/ext/digest/crc32/extconf.rb +21 -0
- data/ext/digest/depend +4 -0
- data/ext/digest/digest.c +3 -2
- data/ext/digest/digest.h +9 -1
- data/ext/digest/md5/depend +11 -0
- data/ext/digest/rmd160/depend +10 -0
- data/ext/digest/sha1/depend +11 -0
- data/ext/digest/sha1/sha1.c +4 -2
- data/ext/digest/sha2/depend +11 -0
- data/lib/digest/version.rb +2 -1
- metadata +29 -2
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# -*- coding: us-ascii -*-
|
|
2
|
+
# frozen_string_literal: false
|
|
3
|
+
|
|
4
|
+
require "mkmf"
|
|
5
|
+
|
|
6
|
+
# BLAKE3 build configuration.
|
|
7
|
+
#
|
|
8
|
+
# The binding is always built from the portable C code (blake3.c,
|
|
9
|
+
# blake3_dispatch.c, blake3_portable.c). On architectures BLAKE3 ships
|
|
10
|
+
# optimized backends for, we additionally compile the SIMD implementations
|
|
11
|
+
# and let blake3_dispatch.c select the fastest one supported by the CPU the
|
|
12
|
+
# program is actually running on (via CPUID on x86). This means a binary
|
|
13
|
+
# built on an AVX-512-capable machine still runs correctly on an older CPU.
|
|
14
|
+
#
|
|
15
|
+
# Each SIMD translation unit must be compiled with its own instruction-set
|
|
16
|
+
# flag, which a single global $CFLAGS can't express, so we emit one explicit
|
|
17
|
+
# object rule per backend at the end (see below). Any x86 backend we do NOT
|
|
18
|
+
# compile is disabled with -DBLAKE3_NO_<ISA>; that macro is honoured both by
|
|
19
|
+
# the dispatcher and by sibling backends (e.g. blake3_avx2.c falls back to
|
|
20
|
+
# SSE4.1 helpers), keeping the set of referenced symbols consistent.
|
|
21
|
+
|
|
22
|
+
objs = %w[blake3init blake3 blake3_dispatch blake3_portable]
|
|
23
|
+
|
|
24
|
+
# Extra per-object compiler flags, keyed by object basename.
|
|
25
|
+
simd_cflags = {}
|
|
26
|
+
|
|
27
|
+
def blake3_disable(macro)
|
|
28
|
+
$CPPFLAGS << " -D#{macro}"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Probe used to confirm the compiler both accepts +flag+ and can compile the
|
|
32
|
+
# intrinsics the backend relies on. It compiles the backend source itself:
|
|
33
|
+
# a small snippet misses assemblers that reject what the compiler emits (e.g.
|
|
34
|
+
# binutils 2.30 on RHEL 8 rejects AVX-512 code from gcc 8.5).
|
|
35
|
+
def blake3_have_isa?(name, flag, snippet)
|
|
36
|
+
checking_for("#{name} intrinsics" + (flag ? " (#{flag})" : "")) do
|
|
37
|
+
try_compile(snippet, flag)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
case RbConfig::CONFIG["host_cpu"]
|
|
42
|
+
when /\A(x86_64|amd64|x64)\z/i
|
|
43
|
+
# Try to detect which SIMD features this x86 machine and compiler has
|
|
44
|
+
x86_backends = [
|
|
45
|
+
["blake3_sse2", "SSE2", ["-msse2", "-arch:SSE2"], "BLAKE3_NO_SSE2"],
|
|
46
|
+
["blake3_sse41", "SSE4.1", ["-msse4.1", "-arch:AVX"], "BLAKE3_NO_SSE41"],
|
|
47
|
+
["blake3_avx2", "AVX2", ["-mavx2", "-arch:AVX2"], "BLAKE3_NO_AVX2"],
|
|
48
|
+
["blake3_avx512", "AVX-512", ["-mavx512f -mavx512vl", "-arch:AVX512"], "BLAKE3_NO_AVX512"],
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
x86_backends.each do |obj, name, flags, no_macro|
|
|
52
|
+
[nil, *flags].any? do |flag|
|
|
53
|
+
if blake3_have_isa?(name, flag, %{#include "#{$srcdir}/#{obj}.c"\n})
|
|
54
|
+
objs << obj
|
|
55
|
+
simd_cflags[obj] = flag
|
|
56
|
+
true
|
|
57
|
+
end
|
|
58
|
+
end or
|
|
59
|
+
blake3_disable(no_macro)
|
|
60
|
+
end
|
|
61
|
+
when /\A(aarch64|arm64)\z/i
|
|
62
|
+
# NEON is part of the AArch64 baseline, so no runtime detection or special
|
|
63
|
+
# compiler flag is needed. Leave BLAKE3_USE_NEON to auto-detect, which is
|
|
64
|
+
# 1 on little-endian AArch64 (see blake3_impl.h).
|
|
65
|
+
objs << "blake3_neon"
|
|
66
|
+
else
|
|
67
|
+
# No optimized backend wired up for this architecture (e.g. 32-bit x86,
|
|
68
|
+
# ppc): build portable-only. Disabling every x86 ISA keeps the dispatcher
|
|
69
|
+
# from referencing backends we didn't compile, and NEON is forced off.
|
|
70
|
+
blake3_disable("BLAKE3_NO_SSE2")
|
|
71
|
+
blake3_disable("BLAKE3_NO_SSE41")
|
|
72
|
+
blake3_disable("BLAKE3_NO_AVX2")
|
|
73
|
+
blake3_disable("BLAKE3_NO_AVX512")
|
|
74
|
+
blake3_disable("BLAKE3_USE_NEON=0")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
$objs = objs.map { |o| "#{o}.#{$OBJEXT}" }
|
|
78
|
+
|
|
79
|
+
have_header("sys/cdefs.h")
|
|
80
|
+
|
|
81
|
+
$preload = %w[digest]
|
|
82
|
+
|
|
83
|
+
create_makefile("digest/blake3")
|
|
84
|
+
|
|
85
|
+
# Emit one explicit compile rule per SIMD backend so each gets its own
|
|
86
|
+
# instruction-set flag. mkmf's implicit .c.o rule compiles every object with
|
|
87
|
+
# the same $(CFLAGS), which can't express e.g. -mavx2 for one file only; an
|
|
88
|
+
# explicit rule with a recipe overrides that implicit rule for these targets.
|
|
89
|
+
# The recipe mirrors mkmf's .c.o rule with the extra flag inserted after
|
|
90
|
+
# $(CFLAGS).
|
|
91
|
+
unless simd_cflags.empty?
|
|
92
|
+
File.open("Makefile", "a") do |mf|
|
|
93
|
+
mf.puts
|
|
94
|
+
mf.puts "# Per-file instruction-set flags for the BLAKE3 SIMD backends."
|
|
95
|
+
simd_cflags.each do |obj, flag|
|
|
96
|
+
target = "#{obj}.#{$OBJEXT}"
|
|
97
|
+
mf.puts "#{target}: $(srcdir)/#{obj}.c"
|
|
98
|
+
mf.puts "\t$(ECHO) compiling #{obj}.c"
|
|
99
|
+
mf.puts "\t$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) #{flag} $(COUTFLAG)$@ -c $(CSRCFLAG)$(srcdir)/#{obj}.c"
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#include "crc32.h"
|
|
2
|
+
|
|
3
|
+
static const uint32_t crc32_table[256] = {
|
|
4
|
+
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
|
5
|
+
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
|
|
6
|
+
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
|
7
|
+
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
|
|
8
|
+
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
|
9
|
+
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
|
10
|
+
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
|
|
11
|
+
0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
|
|
12
|
+
0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
|
13
|
+
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
|
14
|
+
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
|
|
15
|
+
0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
|
16
|
+
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
|
|
17
|
+
0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
|
|
18
|
+
0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
|
19
|
+
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
|
|
20
|
+
0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
|
|
21
|
+
0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
|
22
|
+
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
|
|
23
|
+
0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
|
24
|
+
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
|
25
|
+
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
|
|
26
|
+
0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
|
|
27
|
+
0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
|
28
|
+
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
|
29
|
+
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
|
|
30
|
+
0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
|
31
|
+
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
|
|
32
|
+
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
|
|
33
|
+
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
|
34
|
+
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
|
|
35
|
+
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
int
|
|
39
|
+
CRC32_Init(CRC32_CTX *context)
|
|
40
|
+
{
|
|
41
|
+
context->state = 0xFFFFFFFFu;
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void
|
|
46
|
+
CRC32_Update(CRC32_CTX *context, const uint8_t *data, size_t nbytes)
|
|
47
|
+
{
|
|
48
|
+
uint32_t state = context->state;
|
|
49
|
+
for (size_t index = 0; index < nbytes; index++) {
|
|
50
|
+
state ^= data[index];
|
|
51
|
+
state = (state >> 8) ^ crc32_table[state & 0xff];
|
|
52
|
+
}
|
|
53
|
+
context->state = state;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
int
|
|
57
|
+
CRC32_Finish(CRC32_CTX *context, uint8_t digest[4])
|
|
58
|
+
{
|
|
59
|
+
uint32_t state = context->state;
|
|
60
|
+
state ^= 0xFFFFFFFFu;
|
|
61
|
+
digest[3] = state & 0xff;
|
|
62
|
+
digest[2] = (state >> 8) & 0xff;
|
|
63
|
+
digest[1] = (state >> 16) & 0xff;
|
|
64
|
+
digest[0] = (state >> 24) & 0xff;
|
|
65
|
+
return 1;
|
|
66
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#ifndef _CRC32_H_
|
|
2
|
+
#define _CRC32_H_
|
|
3
|
+
|
|
4
|
+
#include "../defs.h"
|
|
5
|
+
|
|
6
|
+
typedef struct {
|
|
7
|
+
uint32_t state;
|
|
8
|
+
} CRC32_CTX;
|
|
9
|
+
|
|
10
|
+
#ifdef RUBY
|
|
11
|
+
#define CRC32_Init rb_Digest_CRC32_Init
|
|
12
|
+
#define CRC32_Update rb_Digest_CRC32_Update
|
|
13
|
+
#define CRC32_Finish rb_Digest_CRC32_Finish
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
__BEGIN_DECLS
|
|
17
|
+
int CRC32_Init _((CRC32_CTX *));
|
|
18
|
+
void CRC32_Update _((CRC32_CTX *, const uint8_t *, size_t));
|
|
19
|
+
int CRC32_Finish _((CRC32_CTX *, uint8_t[4]));
|
|
20
|
+
__END_DECLS
|
|
21
|
+
|
|
22
|
+
#define CRC32_BLOCK_LENGTH 8
|
|
23
|
+
#define CRC32_DIGEST_LENGTH 4
|
|
24
|
+
#define CRC32_DIGEST_STRING_LENGTH (CRC32_DIGEST_LENGTH * 2 + 1)
|
|
25
|
+
|
|
26
|
+
#endif /* !_CRC32_H_ */
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* $RoughId: crc32init.c,v 1.3 2001/07/13 20:00:43 knu Exp $ */
|
|
2
|
+
/* $Id$ */
|
|
3
|
+
|
|
4
|
+
#include <ruby/ruby.h>
|
|
5
|
+
#include "../digest.h"
|
|
6
|
+
#include "crc32.h"
|
|
7
|
+
|
|
8
|
+
static const rb_digest_metadata_t crc32 = {
|
|
9
|
+
RUBY_DIGEST_API_VERSION,
|
|
10
|
+
CRC32_DIGEST_LENGTH,
|
|
11
|
+
CRC32_BLOCK_LENGTH,
|
|
12
|
+
sizeof(CRC32_CTX),
|
|
13
|
+
(rb_digest_hash_init_func_t)CRC32_Init,
|
|
14
|
+
(rb_digest_hash_update_func_t)CRC32_Update,
|
|
15
|
+
(rb_digest_hash_finish_func_t)CRC32_Finish,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
* Document-class: Digest::CRC32 < Digest::Base
|
|
20
|
+
* A class for calculating message digests using CRC32 algorithm.
|
|
21
|
+
*
|
|
22
|
+
* CRC32 calculates a digest of 32 bits (4 bytes).
|
|
23
|
+
*
|
|
24
|
+
* == Examples
|
|
25
|
+
* require 'digest'
|
|
26
|
+
*
|
|
27
|
+
* # Compute a complete digest
|
|
28
|
+
* Digest::CRC32.hexdigest 'abc' #=> "8eb208f7..."
|
|
29
|
+
*
|
|
30
|
+
* # Compute digest by chunks
|
|
31
|
+
* crc32 = Digest::CRC32.new # =>#<Digest::CRC32>
|
|
32
|
+
* crc32.update "ab"
|
|
33
|
+
* crc32 << "c" # alias for #update
|
|
34
|
+
* crc32.hexdigest # => "352441c2"
|
|
35
|
+
*
|
|
36
|
+
* # Use the same object to compute another digest
|
|
37
|
+
* crc32.reset
|
|
38
|
+
* crc32 << "message"
|
|
39
|
+
* crc32.hexdigest # => "b6bd307f"
|
|
40
|
+
*/
|
|
41
|
+
void
|
|
42
|
+
Init_crc32(void)
|
|
43
|
+
{
|
|
44
|
+
VALUE mDigest, cDigest_Base, cDigest_CRC32;
|
|
45
|
+
|
|
46
|
+
#if 0
|
|
47
|
+
mDigest = rb_define_module("Digest"); /* let rdoc know */
|
|
48
|
+
#endif
|
|
49
|
+
mDigest = rb_digest_namespace();
|
|
50
|
+
cDigest_Base = rb_const_get(mDigest, rb_intern_const("Base"));
|
|
51
|
+
|
|
52
|
+
cDigest_CRC32 = rb_define_class_under(mDigest, "CRC32", cDigest_Base);
|
|
53
|
+
rb_iv_set(cDigest_CRC32, "metadata", rb_digest_make_metadata(&crc32));
|
|
54
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# -*- coding: us-ascii -*-
|
|
2
|
+
# frozen_string_literal: false
|
|
3
|
+
# $RoughId: extconf.rb,v 1.3 2001/08/14 19:54:51 knu Exp $
|
|
4
|
+
# $Id$
|
|
5
|
+
|
|
6
|
+
require "mkmf"
|
|
7
|
+
require File.expand_path("../../digest_conf", __FILE__)
|
|
8
|
+
|
|
9
|
+
if try_static_assert("RUBY_API_VERSION_MAJOR < 3", "ruby/version.h")
|
|
10
|
+
$defs << "-DNDEBUG"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
$objs = [ "crc32init.#{$OBJEXT}" ]
|
|
14
|
+
|
|
15
|
+
digest_conf("crc32")
|
|
16
|
+
|
|
17
|
+
have_header("sys/cdefs.h")
|
|
18
|
+
|
|
19
|
+
$preload = %w[digest]
|
|
20
|
+
|
|
21
|
+
create_makefile("digest/crc32")
|
data/ext/digest/depend
ADDED
data/ext/digest/digest.c
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
************************************************/
|
|
15
15
|
|
|
16
|
+
#define RB_DIGEST_WRAP_METADATA_LINKAGE RUBY_FUNC_EXPORTED
|
|
16
17
|
#include "digest.h"
|
|
17
18
|
|
|
18
19
|
static VALUE rb_mDigest;
|
|
@@ -543,7 +544,7 @@ static const rb_data_type_t metadata_type = {
|
|
|
543
544
|
{0},
|
|
544
545
|
};
|
|
545
546
|
|
|
546
|
-
|
|
547
|
+
RB_DIGEST_WRAP_METADATA_LINKAGE VALUE
|
|
547
548
|
rb_digest_wrap_metadata(const rb_digest_metadata_t *meta)
|
|
548
549
|
{
|
|
549
550
|
return rb_obj_freeze(TypedData_Wrap_Struct(0, &metadata_type, (void *)meta));
|
|
@@ -571,7 +572,7 @@ static rb_digest_metadata_t *
|
|
|
571
572
|
get_digest_base_metadata(VALUE klass)
|
|
572
573
|
{
|
|
573
574
|
VALUE p;
|
|
574
|
-
VALUE obj;
|
|
575
|
+
VALUE obj = Qnil;
|
|
575
576
|
rb_digest_metadata_t *algo;
|
|
576
577
|
|
|
577
578
|
for (p = klass; !NIL_P(p); p = rb_class_superclass(p)) {
|
data/ext/digest/digest.h
CHANGED
|
@@ -73,13 +73,21 @@ rb_id_metadata(void)
|
|
|
73
73
|
# define DIGEST_USE_RB_EXT_RESOLVE_SYMBOL 1
|
|
74
74
|
#endif
|
|
75
75
|
|
|
76
|
+
/* Declarations and definitions of the same function must carry the same
|
|
77
|
+
* attribute on MSVC, and digest.c has to export the definition so that
|
|
78
|
+
* statically linked extensions can find the symbol in libruby. */
|
|
79
|
+
#ifndef RB_DIGEST_WRAP_METADATA_LINKAGE
|
|
80
|
+
# define RB_DIGEST_WRAP_METADATA_LINKAGE extern
|
|
81
|
+
#endif
|
|
82
|
+
|
|
76
83
|
static inline VALUE
|
|
77
84
|
rb_digest_make_metadata(const rb_digest_metadata_t *meta)
|
|
78
85
|
{
|
|
79
86
|
#if defined(EXTSTATIC) && EXTSTATIC
|
|
80
87
|
/* The extension is built as a static library, so safe to refer to
|
|
81
88
|
* rb_digest_wrap_metadata directly. */
|
|
82
|
-
|
|
89
|
+
RB_DIGEST_WRAP_METADATA_LINKAGE
|
|
90
|
+
VALUE rb_digest_wrap_metadata(const rb_digest_metadata_t *meta);
|
|
83
91
|
return rb_digest_wrap_metadata(meta);
|
|
84
92
|
#else
|
|
85
93
|
/* The extension is built as a shared library, so we can't refer
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
md5.o: md5.c md5.h $(srcdir)/../defs.h
|
|
2
|
+
md5init.o: $(LOCAL_HDRS)
|
|
3
|
+
|
|
4
|
+
# AUTOGENERATED DEPENDENCIES START
|
|
5
|
+
md5.o md5init.o: $(srcdir)/../defs.h
|
|
6
|
+
md5.o md5init.o: md5.h
|
|
7
|
+
md5.o: md5.c
|
|
8
|
+
md5init.o: $(srcdir)/../digest.h
|
|
9
|
+
md5init.o: md5cc.h
|
|
10
|
+
md5init.o: md5init.c
|
|
11
|
+
# AUTOGENERATED DEPENDENCIES END
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
rmd160.o: rmd160.c rmd160.h $(srcdir)/../defs.h
|
|
2
|
+
rmd160init.o: $(LOCAL_HDRS)
|
|
3
|
+
|
|
4
|
+
# AUTOGENERATED DEPENDENCIES START
|
|
5
|
+
rmd160.o rmd160init.o: $(srcdir)/../defs.h
|
|
6
|
+
rmd160.o rmd160init.o: rmd160.h
|
|
7
|
+
rmd160.o: rmd160.c
|
|
8
|
+
rmd160init.o: $(srcdir)/../digest.h
|
|
9
|
+
rmd160init.o: rmd160init.c
|
|
10
|
+
# AUTOGENERATED DEPENDENCIES END
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
sha1.o: sha1.c sha1.h $(srcdir)/../defs.h
|
|
2
|
+
sha1init.o: $(LOCAL_HDRS)
|
|
3
|
+
|
|
4
|
+
# AUTOGENERATED DEPENDENCIES START
|
|
5
|
+
sha1.o sha1init.o: $(srcdir)/../defs.h
|
|
6
|
+
sha1.o sha1init.o: sha1.h
|
|
7
|
+
sha1.o: sha1.c
|
|
8
|
+
sha1init.o: $(srcdir)/../digest.h
|
|
9
|
+
sha1init.o: sha1cc.h
|
|
10
|
+
sha1init.o: sha1init.c
|
|
11
|
+
# AUTOGENERATED DEPENDENCIES END
|
data/ext/digest/sha1/sha1.c
CHANGED
|
@@ -220,14 +220,16 @@ int SHA1_Init(SHA1_CTX *context)
|
|
|
220
220
|
*/
|
|
221
221
|
void SHA1_Update(SHA1_CTX *context, const uint8_t *data, size_t len)
|
|
222
222
|
{
|
|
223
|
-
|
|
223
|
+
size_t i;
|
|
224
|
+
uint32_t j;
|
|
224
225
|
|
|
225
226
|
_DIAGASSERT(context != 0);
|
|
226
227
|
_DIAGASSERT(data != 0);
|
|
227
228
|
|
|
228
229
|
j = context->count[0];
|
|
229
230
|
if ((context->count[0] += len << 3) < j)
|
|
230
|
-
context->count[1]
|
|
231
|
+
context->count[1]++;
|
|
232
|
+
context->count[1] += (uint32_t)(len >> 29);
|
|
231
233
|
j = (j >> 3) & 63;
|
|
232
234
|
if ((j + len) > 63) {
|
|
233
235
|
(void)memcpy(&context->buffer[j], data, (i = 64-j));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
sha2.o: sha2.c sha2.h $(srcdir)/../defs.h
|
|
2
|
+
sha2init.o: $(LOCAL_HDRS)
|
|
3
|
+
|
|
4
|
+
# AUTOGENERATED DEPENDENCIES START
|
|
5
|
+
sha2.o sha2init.o: sha2.h
|
|
6
|
+
sha2.o: $(srcdir)/../defs.h
|
|
7
|
+
sha2.o: sha2.c
|
|
8
|
+
sha2init.o: $(srcdir)/../digest.h
|
|
9
|
+
sha2init.o: sha2cc.h
|
|
10
|
+
sha2init.o: sha2init.c
|
|
11
|
+
# AUTOGENERATED DEPENDENCIES END
|
data/lib/digest/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: digest
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Akinori MUSHA
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-10-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Provides a framework for message digest libraries.
|
|
14
14
|
email:
|
|
15
15
|
- knu@idaemons.org
|
|
16
16
|
executables: []
|
|
17
17
|
extensions:
|
|
18
|
+
- ext/digest/blake3/extconf.rb
|
|
18
19
|
- ext/digest/bubblebabble/extconf.rb
|
|
20
|
+
- ext/digest/crc32/extconf.rb
|
|
19
21
|
- ext/digest/extconf.rb
|
|
20
22
|
- ext/digest/md5/extconf.rb
|
|
21
23
|
- ext/digest/rmd160/extconf.rb
|
|
@@ -25,29 +27,54 @@ extra_rdoc_files: []
|
|
|
25
27
|
files:
|
|
26
28
|
- LICENSE.txt
|
|
27
29
|
- README.md
|
|
30
|
+
- ext/digest/blake3/LICENSE_A2
|
|
31
|
+
- ext/digest/blake3/LICENSE_A2LLVM
|
|
32
|
+
- ext/digest/blake3/LICENSE_CC0
|
|
33
|
+
- ext/digest/blake3/blake3.c
|
|
34
|
+
- ext/digest/blake3/blake3.h
|
|
35
|
+
- ext/digest/blake3/blake3_avx2.c
|
|
36
|
+
- ext/digest/blake3/blake3_avx512.c
|
|
37
|
+
- ext/digest/blake3/blake3_dispatch.c
|
|
38
|
+
- ext/digest/blake3/blake3_impl.h
|
|
39
|
+
- ext/digest/blake3/blake3_neon.c
|
|
40
|
+
- ext/digest/blake3/blake3_portable.c
|
|
41
|
+
- ext/digest/blake3/blake3_sse2.c
|
|
42
|
+
- ext/digest/blake3/blake3_sse41.c
|
|
43
|
+
- ext/digest/blake3/blake3init.c
|
|
44
|
+
- ext/digest/blake3/extconf.rb
|
|
28
45
|
- ext/digest/bubblebabble/bubblebabble.c
|
|
46
|
+
- ext/digest/bubblebabble/depend
|
|
29
47
|
- ext/digest/bubblebabble/extconf.rb
|
|
48
|
+
- ext/digest/crc32/crc32.c
|
|
49
|
+
- ext/digest/crc32/crc32.h
|
|
50
|
+
- ext/digest/crc32/crc32init.c
|
|
51
|
+
- ext/digest/crc32/extconf.rb
|
|
30
52
|
- ext/digest/defs.h
|
|
53
|
+
- ext/digest/depend
|
|
31
54
|
- ext/digest/digest.c
|
|
32
55
|
- ext/digest/digest.h
|
|
33
56
|
- ext/digest/digest_conf.rb
|
|
34
57
|
- ext/digest/extconf.rb
|
|
35
58
|
- ext/digest/lib/digest/loader.rb
|
|
36
59
|
- ext/digest/lib/digest/sha2/loader.rb
|
|
60
|
+
- ext/digest/md5/depend
|
|
37
61
|
- ext/digest/md5/extconf.rb
|
|
38
62
|
- ext/digest/md5/md5.c
|
|
39
63
|
- ext/digest/md5/md5.h
|
|
40
64
|
- ext/digest/md5/md5cc.h
|
|
41
65
|
- ext/digest/md5/md5init.c
|
|
66
|
+
- ext/digest/rmd160/depend
|
|
42
67
|
- ext/digest/rmd160/extconf.rb
|
|
43
68
|
- ext/digest/rmd160/rmd160.c
|
|
44
69
|
- ext/digest/rmd160/rmd160.h
|
|
45
70
|
- ext/digest/rmd160/rmd160init.c
|
|
71
|
+
- ext/digest/sha1/depend
|
|
46
72
|
- ext/digest/sha1/extconf.rb
|
|
47
73
|
- ext/digest/sha1/sha1.c
|
|
48
74
|
- ext/digest/sha1/sha1.h
|
|
49
75
|
- ext/digest/sha1/sha1cc.h
|
|
50
76
|
- ext/digest/sha1/sha1init.c
|
|
77
|
+
- ext/digest/sha2/depend
|
|
51
78
|
- ext/digest/sha2/extconf.rb
|
|
52
79
|
- ext/digest/sha2/sha2.c
|
|
53
80
|
- ext/digest/sha2/sha2.h
|