crypto++

Undefined reference to CryptoPP::AlignedAllocate(unsigned int)

泪湿孤枕 提交于 2021-02-08 13:15:22
问题 I am using crypto++ in c++ linux. Here is my simple code: #include <iostream> #include <fstream> #include <string.h> #include "crypto++/cryptlib.h" #include "crypto++/modes.h" #include "crypto++/filters.h" #include "crypto++/aes.h" #include "crypto++/osrng.h" #include "crypto++/strciphr.h" using namespace std; using namespace CryptoPP; ifstream::pos_type size; char * memblock; int length; char * _iv[AES::BLOCKSIZE]; char * keys[AES::MAX_KEYLENGTH]; void encriptCTR(byte * outbyte, const byte *

Linking Crypto++ fails when building a C++ project using CMake

冷暖自知 提交于 2021-02-05 08:00:07
问题 I have the following project structure: myexec/ |-main.cpp |-hashing.cpp |-hashing.h |-CMakeLists.txt My little software needs Crypto++ whose latest version I built under this path: C:\Users\myuser\cryptopp CMakeLists.txt is: cmake_minimum_required (VERSION 3.8) project ("MyExec") add_executable(MyExec "main.cpp", "hashing.h", "hashing.cpp") find_library(CRYPTOPP_LIB cryptopp "C:/Users/myuser/cryptopp/Win32/DLL_Output/Debug") target_link_libraries(MyExec PUBLIC "${CRYPTOPP_LIB}") target

Crypto++ in Eclipse Undefined Reference

只谈情不闲聊 提交于 2021-01-28 21:07:16
问题 I'm trying to use Crypto++ for my Eclipse C++ project using the MinGW toolchain. Problem is, whenever I try to use crypto functions, I get flooded with "undefined reference" errors. Has anyone experienced this before? This is the what I'm getting (truncated): UPDATED g++ -L "C:\\Libraries\\crypto++\\Win32\\DLL_Output\\Debug" -lpthread -lcryptopp -o "Grum Net.exe" "src\\Vault\\VaultNode.o" "src\\User.o" "src\\Grum Net.o" src\Grum Net.o: In function `ZN8CryptoPP18HashTransformationD2Ev': C:

Value after cryptopp base64 encoding/decoding not the same

限于喜欢 提交于 2021-01-28 19:01:14
问题 I'm playing with cryptopp and have trouble with Base64 encoding/decoding. In the following code hypothetically sig value should be equal tsig , but they are different on a last character ( sig bigger then tsig by one symbol). I've tried also change insertLineBreaks parameter in Base64Encoder but the result is same. ... RSASSA_PKCS1v15_SHA_Signer privkey(privateKey); SecByteBlock sbbSignature(privkey.SignatureLength()); privkey.SignMessage(rng, (byte const*) strContents.data(), strContents

CryptoPP::ed25519::Verifier shows different result from libsignal

杀马特。学长 韩版系。学妹 提交于 2021-01-28 11:32:15
问题 I'm trying to implement curve25519 verification with CryptoPP. I tried the libsignal library first, witch shows correct result. Then I tried the same data with CryptoPP, but shows wrong result. Here is the code using libsignal to verify a signature: string pub = str2hex("0504f05568cc7a16fa9b4bc1c9d9294a80b7727e349365f855031a180bf0f80910"); ec_public_key* pub_key; curve_decode_point(&pub_key, (uint8_t*)pub.data(), pub.size(), 0); string message = str2hex(

Elliptic Curve Point Arithmetic in Crypto++

断了今生、忘了曾经 提交于 2021-01-28 06:31:35
问题 #include "include/cryptopp/oids.h" #include "include/cryptopp/eccrypto.h" #include <cstdio> #include <iostream> using namespace std; using namespace CryptoPP; void init() { ECDH<ECP>::Domain ecdhc(ASN1::secp256k1()); auto g_p = ecdhc.GetGroupParameters(); auto g_ec = g_p.GetSubgroupGenerator(); auto g_ec_ = g_p.GetCurve().Subtract(g_p.GetCurve().Add(g_ec, g_ec), g_ec); if(g_p.GetCurve().Equal(g_ec_, g_ec)) printf("P\n"); else printf("NP\n"); } int main() { init(); return 0; } As an example

SHA-256使用以及相关流程说明

孤者浪人 提交于 2020-08-07 15:10:29
使用的库: c r y p t o + + crypto++ c r y p t o + + ;使用语言: c p p cpp c p p ;使用开发工具: v s 2017 vs2017 v s 2 0 1 7 1. 主要思路 2. 关键类的作用 FileSink : a . :a.\space : a . 使用BufferedTransformation将数据写入文件; b . b.\space b . 传递现有的ostream,库将对其进行写入; c . \space c.\space c . 可以让该库为您打开一个ostream(在这种情况下,将使用ios :: trunc打开文件)。 伴随源对象是FileSource→文件写入数据 HexEncoder 将字节编码为基数为16的编码数据。 伙伴解码器是HexDecoder。 HexEncoder和HexDecoder字母为0123456789ABCDEF。 解码器接受大写和小写值。 HexEncoder采用指向BufferedTransformation的指针。 因为使用了指针,所以HexEncoder拥有附加的转换,因此将销毁它。 有关更多详细信息,请参见所有权。 如果您需要将字节数组快速格式化为适合源代码的C样式数组或C字符串,请参阅ArrayEncoder。 StringSource 是字节数组、C 字符串和C+

RSA遇上中国剩余定理

南笙酒味 提交于 2020-08-05 04:41:16
1.Introduction 最近读论文刚好用到了这个,之前只是有耳闻,没有仔细研究过,这里就好好捋一下,会逐步完善 不过貌似CRT(中国剩余定理)的实现更容易被攻击 2. RSA: Overview rsa算法描述如下: 选择两个大素数 \(p、q\) ,计算 \(N = p*q\) (最好保证N在2048bit以上,最新的研究工作已经可以成功分解762bit的N) 计算 \(\phi(N)=(p-1)*(q-1)\) 选择一个 \(e\) 使得 \(gcd(e, \phi(n)) == 1\) ,e由于是作加密使用,故推荐使用小值,推荐使用3、65537( \(2^{16}+1\) ),65537只有两个1bit,所以在幂运算(参加我的另一篇博客: 快速指数算法 )时只需要两次额外的乘法运算;此外,不需要担心使用固定值会造成的安全问题,RSA的安全性不会受影响 计算 \(ed = 1 (\mod\phi(n))\) ,得到 \(d\) 值用于解密 公钥:(N, e),私钥:(N, d) 一次RSA加解密: \[c = m^e \mod N\\ m = d^d \mod N\\ \] 解释: 即 \(m = (m^e)^d = m^{1\mod\phi(N)}=m^{h*\phi(N)+1}\mod N\) , 由欧拉定理 \(a^{\phi(n)}=1 \mod n\)