Some fixes
This commit is contained in:
parent
5a0bddee23
commit
eb2b8ea558
|
@ -8,7 +8,7 @@
|
|||
/checksums/*
|
||||
!/checksums/.keep
|
||||
/lib/*.bundle
|
||||
/lib/digest/blake2b_ext.so
|
||||
/lib/digest/blake2b/ext.so
|
||||
|
||||
*.o
|
||||
*.gem
|
||||
|
|
2
Rakefile
2
Rakefile
|
@ -6,7 +6,7 @@ require 'rake/extensiontask'
|
|||
|
||||
spec = Gem::Specification.load('digest-blake2b.gemspec')
|
||||
|
||||
Rake::ExtensionTask.new('digest/blake2b_ext', spec) do |ext|
|
||||
Rake::ExtensionTask.new('digest/blake2b/ext', spec) do |ext|
|
||||
ext.source_pattern = '*.{c,h}'
|
||||
end
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ Gem::Specification.new do |spec|
|
|||
|
||||
spec.executables = spec.files.grep %r{^exe/}, &File.method(:basename)
|
||||
|
||||
spec.extensions << 'ext/digest/blake2b_ext/extconf.rb'
|
||||
spec.extensions << 'ext/digest/blake2b/ext/extconf.rb'
|
||||
|
||||
spec.add_development_dependency 'bundler' , '~> 2.2'
|
||||
spec.add_development_dependency 'minitest' , '~> 5.11'
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
|
||||
#ifndef BLAKE2_CONFIG_H
|
||||
#define BLAKE2_CONFIG_H
|
||||
|
||||
|
@ -20,23 +21,22 @@
|
|||
#define HAVE_SSE2
|
||||
#endif
|
||||
|
||||
#if defined(__SSSE3__)
|
||||
#ifdef __SSSE3__
|
||||
#define HAVE_SSSE3
|
||||
#endif
|
||||
|
||||
#if defined(__SSE4_1__)
|
||||
#ifdef __SSE4_1__
|
||||
#define HAVE_SSE41
|
||||
#endif
|
||||
|
||||
#if defined(__AVX__)
|
||||
#ifdef __AVX__
|
||||
#define HAVE_AVX
|
||||
#endif
|
||||
|
||||
#if defined(__XOP__)
|
||||
#ifdef __XOP__
|
||||
#define HAVE_XOP
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_AVX2
|
||||
#ifndef HAVE_AVX
|
||||
#define HAVE_AVX
|
||||
|
@ -65,7 +65,7 @@
|
|||
#define HAVE_SSE2
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_SSE2)
|
||||
#ifndef HAVE_SSE2
|
||||
#error "This code requires at least SSE2."
|
||||
#endif
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
|
||||
#ifndef BLAKE2_IMPL_H
|
||||
#define BLAKE2_IMPL_H
|
||||
|
||||
|
@ -19,7 +20,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
|
||||
#if defined(_MSC_VER)
|
||||
#ifdef _MSC_VER
|
||||
#define BLAKE2_INLINE __inline
|
||||
#elif defined(__GNUC__)
|
||||
#define BLAKE2_INLINE __inline__
|
||||
|
@ -32,7 +33,7 @@
|
|||
|
||||
static BLAKE2_INLINE uint32_t load32( const void *src )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
#ifdef NATIVE_LITTLE_ENDIAN
|
||||
uint32_t w;
|
||||
memcpy(&w, src, sizeof w);
|
||||
return w;
|
||||
|
@ -47,7 +48,7 @@ static BLAKE2_INLINE uint32_t load32( const void *src )
|
|||
|
||||
static BLAKE2_INLINE uint64_t load64( const void *src )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
#ifdef NATIVE_LITTLE_ENDIAN
|
||||
uint64_t w;
|
||||
memcpy(&w, src, sizeof w);
|
||||
return w;
|
||||
|
@ -66,7 +67,7 @@ static BLAKE2_INLINE uint64_t load64( const void *src )
|
|||
|
||||
static BLAKE2_INLINE uint16_t load16( const void *src )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
#ifdef NATIVE_LITTLE_ENDIAN
|
||||
uint16_t w;
|
||||
memcpy(&w, src, sizeof w);
|
||||
return w;
|
||||
|
@ -79,7 +80,7 @@ static BLAKE2_INLINE uint16_t load16( const void *src )
|
|||
|
||||
static BLAKE2_INLINE void store16( void *dst, uint16_t w )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
#ifdef NATIVE_LITTLE_ENDIAN
|
||||
memcpy(dst, &w, sizeof w);
|
||||
#else
|
||||
uint8_t *p = ( uint8_t * )dst;
|
||||
|
@ -90,7 +91,7 @@ static BLAKE2_INLINE void store16( void *dst, uint16_t w )
|
|||
|
||||
static BLAKE2_INLINE void store32( void *dst, uint32_t w )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
#ifdef NATIVE_LITTLE_ENDIAN
|
||||
memcpy(dst, &w, sizeof w);
|
||||
#else
|
||||
uint8_t *p = ( uint8_t * )dst;
|
||||
|
@ -103,7 +104,7 @@ static BLAKE2_INLINE void store32( void *dst, uint32_t w )
|
|||
|
||||
static BLAKE2_INLINE void store64( void *dst, uint64_t w )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
#ifdef NATIVE_LITTLE_ENDIAN
|
||||
memcpy(dst, &w, sizeof w);
|
||||
#else
|
||||
uint8_t *p = ( uint8_t * )dst;
|
|
@ -12,19 +12,20 @@
|
|||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
|
||||
#ifndef BLAKE2_H
|
||||
#define BLAKE2_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#ifdef _MSC_VER
|
||||
#define BLAKE2_PACKED(x) __pragma(pack(push, 1)) x __pragma(pack(pop))
|
||||
#else
|
||||
#define BLAKE2_PACKED(x) x __attribute__((packed))
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
@ -188,7 +189,7 @@ extern "C" {
|
|||
/* This is simply an alias for blake2b */
|
||||
int blake2( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -26,16 +26,16 @@
|
|||
#include <intrin.h> /* for _mm_set_epi64x */
|
||||
#endif
|
||||
#include <emmintrin.h>
|
||||
#if defined(HAVE_SSSE3)
|
||||
#ifdef HAVE_SSSE3
|
||||
#include <tmmintrin.h>
|
||||
#endif
|
||||
#if defined(HAVE_SSE41)
|
||||
#ifdef HAVE_SSE41
|
||||
#include <smmintrin.h>
|
||||
#endif
|
||||
#if defined(HAVE_AVX)
|
||||
#ifdef HAVE_AVX
|
||||
#include <immintrin.h>
|
||||
#endif
|
||||
#if defined(HAVE_XOP)
|
||||
#ifdef HAVE_XOP
|
||||
#include <x86intrin.h>
|
||||
#endif
|
||||
|
||||
|
@ -160,7 +160,7 @@ static void blake2b_compress( blake2b_state *S, const uint8_t block[BLAKE2B_BLOC
|
|||
const __m128i r16 = _mm_setr_epi8( 2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9 );
|
||||
const __m128i r24 = _mm_setr_epi8( 3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10 );
|
||||
#endif
|
||||
#if defined(HAVE_SSE41)
|
||||
#ifdef HAVE_SSE41
|
||||
const __m128i m0 = LOADU( block + 00 );
|
||||
const __m128i m1 = LOADU( block + 16 );
|
||||
const __m128i m2 = LOADU( block + 32 );
|
||||
|
@ -297,14 +297,14 @@ int blake2( void *out, size_t outlen, const void *in, size_t inlen, const void *
|
|||
return blake2b(out, outlen, in, inlen, key, keylen);
|
||||
}
|
||||
|
||||
#if defined(SUPERCOP)
|
||||
#ifdef SUPERCOP
|
||||
int crypto_hash( unsigned char *out, unsigned char *in, unsigned long long inlen )
|
||||
{
|
||||
return blake2b( out, BLAKE2B_OUTBYTES, in, inlen, NULL, 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BLAKE2B_SELFTEST)
|
||||
#ifdef BLAKE2B_SELFTEST
|
||||
#include <string.h>
|
||||
#include "blake2-kat.h"
|
||||
int main( void )
|
|
@ -12,6 +12,7 @@
|
|||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
|
||||
#ifndef BLAKE2B_ROUND_H
|
||||
#define BLAKE2B_ROUND_H
|
||||
|
||||
|
@ -80,7 +81,7 @@
|
|||
row2l = _mm_roti_epi64(row2l, -63); \
|
||||
row2h = _mm_roti_epi64(row2h, -63); \
|
||||
|
||||
#if defined(HAVE_SSSE3)
|
||||
#ifdef HAVE_SSSE3
|
||||
#define DIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \
|
||||
t0 = _mm_alignr_epi8(row2h, row2l, 8); \
|
||||
t1 = _mm_alignr_epi8(row2l, row2h, 8); \
|
||||
|
@ -136,7 +137,7 @@
|
|||
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SSE41)
|
||||
#ifdef HAVE_SSE41
|
||||
#include "blake2b-load-sse41.h"
|
||||
#else
|
||||
#include "blake2b-load-sse2.h"
|
|
@ -1,3 +1,3 @@
|
|||
require 'mkmf'
|
||||
$CFLAGS += ' -Wall -Wextra -std=c99 -pedantic -Wno-long-long'
|
||||
create_makefile 'digest/blake2b_ext'
|
||||
create_makefile 'digest/blake2b/ext'
|
|
@ -100,7 +100,7 @@ VALUE m_blake2_digest(VALUE self, VALUE _input, VALUE _representation) {
|
|||
return result;
|
||||
}
|
||||
|
||||
void Init_blake2b_ext() {
|
||||
void Init_ext() {
|
||||
mDigest = rb_define_module("Digest");
|
||||
|
||||
mDigest_cBlake2 = rb_define_class_under(mDigest, "Blake2b", rb_cObject);
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'digest/blake2b_ext'
|
||||
require 'digest/blake2b/ext'
|
||||
|
||||
require 'digest/blake2b/key'
|
||||
require 'digest/blake2b/version'
|
||||
|
|
Loading…
Reference in New Issue