Browse Source

GOSTD implemntation

master
orignal 7 years ago
parent
commit
f3f7ac9cda
  1. 10
      src/server/shared/Crypto.cpp
  2. 2
      src/server/shared/Crypto.h
  3. 1058
      src/server/shared/Gost.cpp
  4. 24
      src/server/shared/Gost.h

10
src/server/shared/Crypto.cpp

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "Crypto.h"
#include "Gost.h"
namespace Crypto
{
@ -22,4 +23,13 @@ namespace Crypto @@ -22,4 +23,13 @@ namespace Crypto
{
return SHA256(SHA256(data));
}
BinaryData GOSTD(BinaryData data)
{
uint8_t hash1[64];
i2p::crypto::GOSTR3411_2012_512 (&data[0], data.size (), hash1);
std::vector<byte> hash;
i2p::crypto::GOSTR3411_2012_256 (hash1, 64, &hash[0]);
return std::vector<byte>(hash.begin(), hash.end());
}
}

2
src/server/shared/Crypto.h

@ -12,6 +12,8 @@ namespace Crypto @@ -12,6 +12,8 @@ namespace Crypto
BinaryData SHA256(BinaryData data);
BinaryData SHA256(std::string data);
BinaryData SHA256D(BinaryData data);
BinaryData GOSTD(BinaryData data);
}
#endif

1058
src/server/shared/Gost.cpp

File diff suppressed because it is too large Load Diff

24
src/server/shared/Gost.h

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
/*
* Copyright (c) 2013-2017, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
*/
#ifndef GOST_H__
#define GOST_H__
#include <inttypes.h>
namespace i2p
{
namespace crypto
{
// Big Endian
void GOSTR3411_2012_256 (const uint8_t * buf, size_t len, uint8_t * digest);
void GOSTR3411_2012_512 (const uint8_t * buf, size_t len, uint8_t * digest);
}
}
#endif
Loading…
Cancel
Save