gpt4 book ai didi

c - openssl命令行解密aes ctr 128

转载 作者:太空宇宙 更新时间:2023-11-03 23:55:13 30 4
gpt4 key购买 nike

我正在使用以下工作代码来解密文件:

#include <openssl/aes.h>
#include <stdio.h>
#include <string.h>

struct ctr_state {
unsigned char ivec[16];
unsigned int num;
unsigned char ecount[16];
};

FILE *fp;
FILE *rp;
FILE *op;
size_t count;
char * buffer;
AES_KEY key;

int bytes_read, bytes_written;
unsigned char indata[AES_BLOCK_SIZE];
unsigned char outdata[AES_BLOCK_SIZE];
unsigned char ckey[] = "1234567890123456";
unsigned char iv[8] = {0};
struct ctr_state state;

void init_ctr(struct ctr_state *state, const unsigned char iv[8]){
state->num = 0;
memset(state->ecount, 0, 16);
memset(state->ivec + 8, 0, 8);
memcpy(state->ivec, iv, 8);
}

void decrypt(){
//Opening files where text cipher text is read and the plaintext recovered
rp=fopen("c:\\temp\\decrypted.mp3","wb");
op=fopen("c:\\temp\\encrypted.mp3","rb");
if (rp==NULL) {fputs ("File error",stderr); return;}
if (op==NULL) {fputs ("File error",stderr); return;}

//Initializing the encryption KEY
AES_set_encrypt_key(ckey, 128, &key);
init_ctr(&state, iv);//Counter call

//Encrypting Blocks of 16 bytes and writing the output.txt with ciphertext
while (1) {
bytes_read = fread(indata, 1, AES_BLOCK_SIZE, op);
AES_ctr128_encrypt(indata, outdata, bytes_read, &key, state.ivec, state.ecount, &state.num);
bytes_written = fwrite(outdata, 1, bytes_read, rp);
if (bytes_read < AES_BLOCK_SIZE)
break;
}
fclose (rp);
fclose (op);
}

int main(int argc, char *argv[]){
decrypt();
return 0;
}

是否可以使用 openssl 命令行做同样的事情?

据我所知,没有 -aes-128-ctr 密码,但 openssl 中是否有任何等效密码?

最佳答案

我检查过的任何版本的 openssl(1) 命令行工具似乎都不支持任何密码的计数器模式。

关于c - openssl命令行解密aes ctr 128,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9434265/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com