Skip to content

Commit

Permalink
add blake3
Browse files Browse the repository at this point in the history
  • Loading branch information
cielavenir committed Apr 4, 2022
1 parent 2e403be commit 1a4e078
Show file tree
Hide file tree
Showing 6 changed files with 1,134 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CPP/7zip/7zip_gcc_additional.mak
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ $O/md5.o: ../../../../Codecs/hashes/md5.c
$(CC) $(CFLAGS) $<
$O/sha512.o: ../../../../Codecs/hashes/sha512.c
$(CC) $(CFLAGS) $<
$O/blake3.o: ../../../../Codecs/hashes/blake3.c
$(CC) $(CFLAGS) $<

# Compile hashes method
$O/Md2Reg.o: ../../../Common/Md2Reg.cpp
Expand All @@ -215,7 +217,9 @@ $O/XXH32Reg.o: ../../../Common/XXH32Reg.cpp
$(CXX) $(CXXFLAGS) $<
$O/XXH64Reg.o: ../../../Common/XXH64Reg.cpp
$(CXX) $(CXXFLAGS) $<

$O/Blake3Reg.o: ../../../Common/Blake3Reg.cpp
$(CXX) $(CXXFLAGS) $<

clean2:
$(RM) zstd_build
# $(RM) lz4_build
Expand Down
2 changes: 2 additions & 0 deletions CPP/7zip/Bundles/Format7zF/Arc_gcc.mak
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,12 @@ HASHES_OBJS = \
$O/Sha512Reg.o \
$O/XXH32Reg.o \
$O/XXH64Reg.o \
$O/Blake3Reg.o \
$O/md2.o \
$O/md4.o \
$O/md5.o \
$O/sha512.o \
$O/blake3.o \

C_OBJS = \
$O/7zBuf2.o \
Expand Down
39 changes: 39 additions & 0 deletions CPP/7zip/Compress/Blake3/makefile.gcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
PROG = Blake3
DEF_FILE = ../Codec.def

# IS_X64 = 1
# USE_ASM = 1
# ST_MODE = 1

ifdef SystemDrive

LOCAL_FLAGS_WIN = \
-D_7ZIP_LARGE_PAGES \
$(LOCAL_FLAGS_ST) \

SYS_OBJS = \

else

SYS_OBJS = \
$O/MyWindows.o \

endif

LOCAL_FLAGS = \
-DEXTERNAL_CODECS \
$(LOCAL_FLAGS_WIN) \
$(LOCAL_FLAGS_ST) \

COMPRESS_OBJS_2 = \
$O/CodecExports.o \
$O/DllExportsCompress.o \
$O/Blake3Reg.o \
$O/blake3.o \

OBJS = \
$(COMPRESS_OBJS_2) \
$(SYS_OBJS) \
$(COMMON_OBJS) \

include ../../7zip_gcc.mak
43 changes: 43 additions & 0 deletions CPP/Common/Blake3Reg.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Blake3Reg.cpp /TR 2021-04-06

#include "StdAfx.h"

#include "../../C/CpuArch.h"

EXTERN_C_BEGIN
#include "../../Codecs/hashes/blake3.h"
EXTERN_C_END

#include "../Common/MyCom.h"
#include "../7zip/Common/RegisterCodec.h"

// BLAKE3
class CBLAKE3Hasher:
public IHasher,
public CMyUnknownImp
{
blake3_hasher _ctx;
Byte mtDummy[1 << 7];

public:
CBLAKE3Hasher() { blake3_hasher_init(&_ctx); }

MY_UNKNOWN_IMP1(IHasher)
INTERFACE_IHasher(;)
};

STDMETHODIMP_(void) CBLAKE3Hasher::Init() throw()
{
blake3_hasher_init(&_ctx);
}

STDMETHODIMP_(void) CBLAKE3Hasher::Update(const void *data, UInt32 size) throw()
{
blake3_hasher_update(&_ctx, data, size);
}

STDMETHODIMP_(void) CBLAKE3Hasher::Final(Byte *digest) throw()
{
blake3_hasher_finalize(&_ctx, digest, BLAKE3_OUT_LEN);
}
REGISTER_HASHER(CBLAKE3Hasher, 0x20a, "BLAKE3", BLAKE3_OUT_LEN)
Loading

0 comments on commit 1a4e078

Please sign in to comment.