示例#1
0
void ECRYPT_decrypt_packet(
  ECRYPT_ctx* ctx,
  const u8* iv,
  const u8* ciphertext,
  u8* plaintext,
  u32 msglen)
{
  ECRYPT_ivsetup(ctx, iv);
  ECRYPT_decrypt_bytes(ctx, ciphertext, plaintext, msglen);
}
示例#2
0
void ECRYPT_process_bytes(
  int action,                 /* 0 = encrypt; 1 = decrypt; */
  ECRYPT_ctx* ctx, 
  const u8* input, 
  u8* output, 
  u32 msglen)                 /* Message length in bytes. */ 
{
  if (action == 0)
    ECRYPT_encrypt_bytes(ctx, input, output, msglen);
  else
    ECRYPT_decrypt_bytes(ctx, input, output, msglen);
}
示例#3
0
int main(int argc, char **argv) {
    char *input, *output;
    unsigned char *input_data;
    struct stat in_st;
    int input_fd, output_fd;
    int i;
    unsigned char tmp[64];
    ECRYPT_ctx ctx;

    if (argc != 3) {
    	fprintf(stderr, "usage: %s input output\n", argv[0]);
    	exit(EXIT_FAILURE);
    }

    input = argv[1]; output = argv[2];

    init_ctx(&ctx);

    if (stat(input, &in_st) == -1) {
    	perror("stat");
    	exit(EXIT_FAILURE);
    }

    input_fd = open(input, O_RDONLY);
    if (input_fd == -1) {
    	perror("open");
    	exit(EXIT_FAILURE);
    }

    output_fd = creat(output, S_IRWXU);
    if (output_fd == -1) {
    	perror("open");
    	exit(EXIT_FAILURE);
    }

    input_data = mmap(NULL, in_st.st_size, PROT_READ, MAP_SHARED, input_fd, 0);
    if (input_data == (void *) -1) {
    	perror("mmap");
    	exit(EXIT_FAILURE);
    }

    ECRYPT_init();
    for (i = 0; i < (in_st.st_size / 64); i++) {
    	ECRYPT_decrypt_bytes(&ctx, input_data + 64 * i, tmp, 64);
    	write(output_fd, tmp, 64); 
    }

    close(output_fd);
    munmap(input_data, in_st.st_size);
    close(input_fd);

    exit(EXIT_SUCCESS);
}
示例#4
0
void ECRYPT_process_packet(
  int action,
  ECRYPT_ctx* ctx,
  const u8* iv,
  const u8* input,
  u8* output,
  u32 msglen)
{
  ECRYPT_ivsetup(ctx, iv);

#ifdef ECRYPT_HAS_SINGLE_BYTE_FUNCTION
  ECRYPT_process_bytes(action, ctx, input, output, msglen);
#else
  if (action == 0)
    ECRYPT_encrypt_bytes(ctx, input, output, msglen);
  else
    ECRYPT_decrypt_bytes(ctx, input, output, msglen);
#endif
}