Tag: openssl

没有BIO的ASN1_TIME_printfunction?

正如这个问题所描述的: Openssl C ++有效期 ,有可能将ASN1时间写入BIO缓冲区,然后将其读回自定义缓冲区buf : BIO *bio; int write = 0; bio = BIO_new(BIO_s_mem()); if (bio) { if (ASN1_TIME_print(bio, tm)) write = BIO_read(bio, buf, len-1); BIO_free(bio); } buf[write]=’\0′; return write; 如果不使用BIO,怎么能实现呢? 仅当OPENSSL_NO_BIO时,才会出现ASN1_TIME_print函数。 有没有办法将时间直接写入给定的缓冲区?

Openssl aes.h 未定义引用

我尝试使用OpenSSL ibaries进行AES解密的简单测试程序。 编译器/链接器向我显示错误。 编译器:Dev-Cpp [Linker error] undefined reference to `AES_set_decrypt_key’ [Linker error] undefined reference to `AES_decrypt’ 码: #include #include int main(){ AES_KEY k; unsigned char key[]=”2641cf97291c6ea02b930a4e2a824990″; unsigned char in[]=”adc8f4ad114433ffaf4597c9738d257c504db763c29d238aa05bd21e1107809f”; unsigned char out[150]; AES_set_decrypt_key(key, 256, &k); AES_decrypt(in, out, &k); printf(“%s\n”, out); } TNX

X.509v3 ASN.1到C数据结构

我正在尝试在C(OpenSSL)中创建X509代理证书请求(ProxyCertInfo扩展RFC3820 ),但我无法弄清楚应该如何定义ProxyCertInfo的数据结构。 RFC定义ASN.1语言如下: PKIXproxy88 { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) id-mod(0) proxy-cert-extns(25) } DEFINITIONS EXPLICIT TAGS ::= BEGIN — EXPORTS ALL — — IMPORTS NONE — — PKIX specific OIDs id-pkix OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) } — private certificate extensions id-pe OBJECT IDENTIFIER ::= { id-pkix […]

如何从OpenSSL中的perl脚本生成程序集文件

在OpenSSL(版本1.1.0e)的开源代码中,我看到一些函数定义是由文件夹中存在的perl文件生成的。 在加密中每个文件夹中的build.info文件中,他们写了一些行来从相应的.pl生成.s。 例如: 在crypto/aes/build.info生成crypto/aes/build.info : GENERATE[aesp8-ppc.s]=asm/aesp8-ppc.pl $(PERLASM_SCHEME) 在crypto/build.info生成crypto/build.info : GENERATE[ppccpuid.s]=ppccpuid.pl $(PERLASM_SCHEME) 而且在主Makefile(生成的makefile)中,有一些行如下: crypto/aes/aes-x86_64.o: crypto/aes/aes-x86_64.s $(CC) -I. -Icrypto/include -Iinclude $(CFLAGS) $(LIB_CFLAGS) -MMD -MF crypto/aes/aes-x86_64.d.tmp -MT $@ -c -o $@ crypto/aes/aes-x86_64.s @touch crypto/aes/aes-x86_64.d.tmp @if cmp crypto/aes/aes-x86_64.d.tmp crypto/aes/aes-x86_64.d > /dev/null 2> /dev/null; then \ rm -f crypto/aes/aes-x86_64.d.tmp; \ else \ mv crypto/aes/aes-x86_64.d.tmp crypto/aes/aes-x86_64.d; \ fi 其次是: crypto/aes/aes-x86_64.s: crypto/aes/asm/aes-x86_64.pl […]

C – 如何正确使用OpenSSL的BIO_write()

我是OpenSSL的新手。 我理解BIO_write(BIO * b,const void * buf,int len)需要在循环中调用,但我不完全确定我是否正确使用它。 我写了这样一个函数: int32_t SendPacket(BIO * const pBio, const unsigned char * const pPacket, const int nPacketLength) { int32_t nPos = 0; if (!pBio || !pPacket || !nPacketLength) return -1; while (nPos < nPacketLength) { int32_t nNumberOfBytesWritten = BIO_write(pBio, &pPacket[nPos], nPacketLength – nPos); if (nNumberOfBytesWritten <= 0) { if […]

如何将pem公钥转换为openssl RSA *结构

假设我必须像这样公开pem键 —–BEGIN PUBLIC KEY—– MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC7vbqajDw4o6gJy8UtmIbkcpnk O3Kwc4qsEnSZp/TR+fQi62F79RHWmwKOtFmwteURgLbj7D/WGuNLGOfa/2vse3G2 eHnHl5CB8ruRX9fBl/KgwCVr2JaEuUm66bBQeP5XeBotdR4cvX38uPYivCDdPjJ1 QWPdspTBKcxeFbccDwIDAQAB —–END PUBLIC KEY—– 我想使用openssl int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to,RSA *rsa, int padding) 。 如何将pem键转换为RSA *rsa结构? 仅供参考:我不能使用BIO,因为我只想将openssl移植到没有UNIX文件系统的引导加载程序中。 我能做的唯一方法是将公钥转换为C数组。

OS X上带有胖库的架构x86_64的未定义符号

我自己从源代码构建了libcrypto.a和libssl.a ,将darwin64-x86_64-cc (对于64位)和darwin-i386-cc (对于32位)指定为OpenSSL的configure脚本。 使用lipo创建了fat库,并将它们作为依赖项添加到我的Xcode项目中。 但是,我得到一个未定义的符号错误: undefined symbols for architecture x86_64: “_OPENSSL_ia32cap_P”, referenced from: _AES_cbc_encrypt in libcrypto.a(aes-x86_64.o) ld: symbol(s) not found for architecture x86_64 注意:使用相同的技术适用于iOS。 lipo -detailed_info libcrypto.a揭示: Fat header in: libcrypto.a fat_magic 0xcafebabe nfat_arch 2 architecture i386 cputype CPU_TYPE_I386 cpusubtype CPU_SUBTYPE_I386_ALL offset 48 size 2700624 align 2^2 (4) architecture x86_64 cputype CPU_TYPE_X86_64 cpusubtype CPU_SUBTYPE_X86_64_ALL […]

以编程方式validationX509证书和私钥匹配

我使用EVP_aes_256_cbc()密码创建了一个RSA密钥对。 私钥是PEM编码的并且具有密码短语。 这需要用户输入密码。 这是创建私钥调用: //Save private key bio_priv = BIO_new_file(full_asymKeyFilePath.c_str(), “a+”); if (PEM_write_bio_RSAPrivateKey( bio_priv, //BIO handle rsa, //Key handle EVP_aes_256_cbc(), //Cipher encoding format pwd, //Password pwd_len, //Password length NULL, //Callback NULL //Not sure ) != 1) { //report err } 然后我生成了一个证书并用私钥签名。 //Sign the certificate with the generated key if (!X509_sign(cert, evpKey, EVP_sha1())){ //report err } […]

md5参考错误

我在我的mac上编译了一个正确工作的md5程序但是当我尝试在我的ubuntu发行版上编译它时出错了: /tmp/ccKBJiV3.o: In function `str2md5′: md5.c:(.text+0x33): undefined reference to `MD5_Init’ md5.c:(.text+0x5b): undefined reference to `MD5_Update’ md5.c:(.text+0x79): undefined reference to `MD5_Update’ md5.c:(.text+0xa2): undefined reference to `MD5_Final’ collect2: ld returned 1 exit status 以下是我的主要代码: #include #include #include #include “md5.h” #include #include int main(int argc, char *argv[]) { char *output = str2md5(argv[1], strlen(argv[1])); printf(“%s\n”, output); free(output); return 0; […]

需要使用openssl加密和解密文件的示例C代码

我在Linux C中编写代码。我需要使用openssl加密和解密文件。 目前我正在使用系统命令“des3 -e -nosalt -k 0123456789012345 -in inp_file -out out_file”进行加密,使用“des3 -d -nosalt -k 0123456789012345 -in inp_file -out out_file”进行解密。 我应该在哪里获得示例代码以使用C API执行相同的操作。