Compare commits
No commits in common. "3a7a71c7fdbbea60498d25a27d9fd63d57f507c0" and "5ad6f0d58f6adea4595e8f120208ee13dffe7b96" have entirely different histories.
3a7a71c7fd
...
5ad6f0d58f
8 changed files with 8 additions and 145 deletions
73
.cproject
73
.cproject
|
@ -1,73 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
|
||||||
<cconfiguration id="cdt.managedbuild.toolchain.gnu.macosx.base.1386600442">
|
|
||||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.macosx.base.1386600442" moduleId="org.eclipse.cdt.core.settings" name="Default">
|
|
||||||
<externalSettings/>
|
|
||||||
<extensions>
|
|
||||||
<extension id="org.eclipse.cdt.core.MachO64" point="org.eclipse.cdt.core.BinaryParser"/>
|
|
||||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
|
||||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
|
||||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
|
||||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
|
||||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
|
||||||
</extensions>
|
|
||||||
</storageModule>
|
|
||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
|
||||||
<configuration buildProperties="" id="cdt.managedbuild.toolchain.gnu.macosx.base.1386600442" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
|
|
||||||
<folderInfo id="cdt.managedbuild.toolchain.gnu.macosx.base.1386600442.1551296983" name="/" resourcePath="">
|
|
||||||
<toolChain id="cdt.managedbuild.toolchain.gnu.macosx.base.386985440" name="MacOSX GCC" superClass="cdt.managedbuild.toolchain.gnu.macosx.base">
|
|
||||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.MachO64" id="cdt.managedbuild.target.gnu.platform.macosx.base.1885573856" name="Debug Platform" osList="macosx" superClass="cdt.managedbuild.target.gnu.platform.macosx.base"/>
|
|
||||||
<builder id="cdt.managedbuild.target.gnu.builder.macosx.base.1888590002" managedBuildOn="false" name="Gnu Make Builder.Default" superClass="cdt.managedbuild.target.gnu.builder.macosx.base"/>
|
|
||||||
<tool id="cdt.managedbuild.tool.macosx.c.linker.macosx.base.203162375" name="MacOS X C Linker" superClass="cdt.managedbuild.tool.macosx.c.linker.macosx.base"/>
|
|
||||||
<tool id="cdt.managedbuild.tool.macosx.cpp.linker.macosx.base.380032459" name="MacOS X C++ Linker" superClass="cdt.managedbuild.tool.macosx.cpp.linker.macosx.base">
|
|
||||||
<inputType id="cdt.managedbuild.tool.macosx.cpp.linker.input.1178315229" superClass="cdt.managedbuild.tool.macosx.cpp.linker.input">
|
|
||||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
|
||||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
|
||||||
</inputType>
|
|
||||||
</tool>
|
|
||||||
<tool id="cdt.managedbuild.tool.gnu.assembler.macosx.base.2122297325" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.macosx.base">
|
|
||||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.382562785" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
|
||||||
</tool>
|
|
||||||
<tool id="cdt.managedbuild.tool.gnu.archiver.macosx.base.763285879" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.macosx.base"/>
|
|
||||||
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.base.518702814" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.base">
|
|
||||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.80838163" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
|
||||||
</tool>
|
|
||||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.macosx.base.1842847648" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.base">
|
|
||||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1789278916" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
|
||||||
</tool>
|
|
||||||
</toolChain>
|
|
||||||
</folderInfo>
|
|
||||||
</configuration>
|
|
||||||
</storageModule>
|
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
|
||||||
</cconfiguration>
|
|
||||||
</storageModule>
|
|
||||||
<storageModule moduleId="scannerConfiguration">
|
|
||||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
|
||||||
</storageModule>
|
|
||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
|
||||||
<project id="c-multihash.null.624575767" name="c-multihash"/>
|
|
||||||
</storageModule>
|
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
|
||||||
<storageModule moduleId="refreshScope"/>
|
|
||||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
|
|
||||||
<buildTargets>
|
|
||||||
<target name="all" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
|
||||||
<buildCommand>make</buildCommand>
|
|
||||||
<buildTarget>all</buildTarget>
|
|
||||||
<stopOnError>true</stopOnError>
|
|
||||||
<useDefaultCommand>true</useDefaultCommand>
|
|
||||||
<runAllBuilders>true</runAllBuilders>
|
|
||||||
</target>
|
|
||||||
<target name="clean" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
|
||||||
<buildCommand>make</buildCommand>
|
|
||||||
<buildArguments/>
|
|
||||||
<buildTarget>clean</buildTarget>
|
|
||||||
<stopOnError>true</stopOnError>
|
|
||||||
<useDefaultCommand>true</useDefaultCommand>
|
|
||||||
<runAllBuilders>true</runAllBuilders>
|
|
||||||
</target>
|
|
||||||
</buildTargets>
|
|
||||||
</storageModule>
|
|
||||||
</cproject>
|
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -3,8 +3,3 @@
|
||||||
!.gitignore
|
!.gitignore
|
||||||
!Makefile
|
!Makefile
|
||||||
!**/
|
!**/
|
||||||
|
|
||||||
*.o
|
|
||||||
*.a
|
|
||||||
.settings/language.settings.xml
|
|
||||||
|
|
||||||
|
|
27
.project
27
.project
|
@ -1,27 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>c-multihash</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
|
||||||
<triggers>clean,full,incremental,</triggers>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
|
||||||
<triggers>full,incremental,</triggers>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
|
||||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
|
||||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
|
||||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
5
LICENSE
5
LICENSE
|
@ -1,9 +1,6 @@
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2019 AGORISE, LTD.
|
Copyright (c) 2016 Protocol Labs, Inc
|
||||||
An International Business Company, Cyprus Reg# ΗΕ375959
|
|
||||||
|
|
||||||
Also contains works from Protocol Labs, Inc. Copyright (c) 2016.
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
10
Makefile
10
Makefile
|
@ -1,8 +1,6 @@
|
||||||
DEBUG=true
|
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
RM = rm -f
|
RM = rm -f
|
||||||
CFLAGS = -fPIC -O0 -std=c99 \
|
CFLAGS = -fPIC -g -O2 -std=c99 \
|
||||||
-Wall -Wextra -pedantic -Werror \
|
-Wall -Wextra -pedantic -Werror \
|
||||||
-Wdeclaration-after-statement \
|
-Wdeclaration-after-statement \
|
||||||
-Wno-format-zero-length \
|
-Wno-format-zero-length \
|
||||||
|
@ -12,14 +10,10 @@ CFLAGS = -fPIC -O0 -std=c99 \
|
||||||
-Wunused \
|
-Wunused \
|
||||||
-Wvla
|
-Wvla
|
||||||
|
|
||||||
ifdef DEBUG
|
|
||||||
CFLAGS += -g3
|
|
||||||
endif
|
|
||||||
|
|
||||||
LDFLAGS = -g
|
LDFLAGS = -g
|
||||||
LDLIBS =
|
LDLIBS =
|
||||||
|
|
||||||
TARGET_LIB = libmultihash.a
|
TARGET_LIB = mulithash.a
|
||||||
TARGET_BIN = multihash
|
TARGET_BIN = multihash
|
||||||
|
|
||||||
SRCS = src/hashes.c src/errors.c src/multihash.c
|
SRCS = src/hashes.c src/errors.c src/multihash.c
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
|
|
||||||
// definitions of hash functions
|
// definitions of hash functions
|
||||||
|
|
|
@ -3,27 +3,6 @@
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* Functions for working with a multihash.
|
|
||||||
* A multihash is a hash with a prefix "code" that
|
|
||||||
* helps determine what type of hash this is.
|
|
||||||
* code name
|
|
||||||
* 0x00 identity
|
|
||||||
* 0x11 sha1
|
|
||||||
* 0x12 sha2-256
|
|
||||||
* 0x13 sha2-512
|
|
||||||
* 0x14 sha3-512
|
|
||||||
* 0x15 sha3-384
|
|
||||||
* 0x16 sha3-256
|
|
||||||
* 0x17 sha3-224
|
|
||||||
* 0x18 shake-128
|
|
||||||
* 0x19 shake-256
|
|
||||||
* 0x40 blake2b
|
|
||||||
* 0x41 blake2s
|
|
||||||
* # 0x0400-0x040f reserved for application specific functions
|
|
||||||
* # 0x14 formerly had the name "sha3", now deprecated
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns hash code or error (which is < 0)
|
* returns hash code or error (which is < 0)
|
||||||
* @param mh the multihash
|
* @param mh the multihash
|
||||||
|
@ -47,7 +26,7 @@ int mh_multihash_length(const unsigned char *multihash, size_t len);
|
||||||
* @param digest the results
|
* @param digest the results
|
||||||
* @returns error if less than zero, otherwise 0
|
* @returns error if less than zero, otherwise 0
|
||||||
*/
|
*/
|
||||||
int mh_multihash_digest(const unsigned char *multihash, size_t len,
|
int mh_multihash_digest(unsigned char *multihash, size_t len,
|
||||||
unsigned char **digest, size_t *digest_len);
|
unsigned char **digest, size_t *digest_len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +44,7 @@ int mh_new_length(int code, size_t digest_len);
|
||||||
* @param digest the data within the multihash
|
* @param digest the data within the multihash
|
||||||
* @returns error (if < 0) or 0
|
* @returns error (if < 0) or 0
|
||||||
*/
|
*/
|
||||||
int mh_new(unsigned char* buffer, int code, const unsigned char *digest,
|
int mh_new(unsigned char *buffer, int code, const unsigned char *digest,
|
||||||
size_t digest_len);
|
size_t digest_len);
|
||||||
|
|
||||||
#endif /* end of include guard */
|
#endif /* end of include guard */
|
||||||
|
|
|
@ -85,14 +85,14 @@ int mh_multihash_length(const unsigned char *mh, size_t len) {
|
||||||
* @param digest the results
|
* @param digest the results
|
||||||
* @returns error if less than zero, otherwise 0
|
* @returns error if less than zero, otherwise 0
|
||||||
*/
|
*/
|
||||||
int mh_multihash_digest(const unsigned char *multihash, size_t len, unsigned char **digest,
|
int mh_multihash_digest(unsigned char *multihash, size_t len, unsigned char **digest,
|
||||||
size_t *digest_len) {
|
size_t *digest_len) {
|
||||||
int err = check_multihash(multihash, len);
|
int err = check_multihash(multihash, len);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
(*digest_len) = (size_t) mh_multihash_length(multihash, len);
|
(*digest_len) = (size_t) mh_multihash_length(multihash, len);
|
||||||
(*digest) = (unsigned char*)multihash + 2; // Always true without varint
|
(*digest) = multihash + 2; // Always true without varint
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ int mh_new_length(int code, size_t hash_len) {
|
||||||
* @param digest the data within the multihash
|
* @param digest the data within the multihash
|
||||||
* @returns error (if < 0) or 0
|
* @returns error (if < 0) or 0
|
||||||
*/
|
*/
|
||||||
int mh_new(unsigned char* buffer, int code, const unsigned char *digest,
|
int mh_new(unsigned char *buffer, int code, const unsigned char *digest,
|
||||||
size_t digest_len) {
|
size_t digest_len) {
|
||||||
if (code & VARINT_MASK)
|
if (code & VARINT_MASK)
|
||||||
return MH_E_VARINT_NOT_SUPPORTED;
|
return MH_E_VARINT_NOT_SUPPORTED;
|
||||||
|
|
Loading…
Reference in a new issue