MCPcopy Create free account
hub / github.com/acl-dev/acl / passwd_decrypt

Function passwd_decrypt

app/net_tools/global/passwd_crypt.cpp:49–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49char* passwd_decrypt(const char* in)
50{
51 const char* myname = "passwd_decrypt";
52 mbedtls_des3_context ctx;
53 unsigned char iv[8];
54 unsigned char* buf;
55 char* data;
56 int n;
57
58 if (mbedtls_des3_set3key_dec(&ctx, des3_test_keys) != 0)
59 {
60 acl_msg_error("%s: des3_set3key_dec error!", myname);
61 return NULL;
62 }
63
64 n = acl_base64_decode(in, &data);
65 if (n < 0)
66 {
67 acl_msg_error("%s: acl_base64_decode error!", myname);
68 return NULL;
69 }
70
71 memcpy(iv, des3_test_iv, 8);
72
73 n += 8 - n % 8 + 8;
74 buf = (unsigned char*) acl_mycalloc(1, n);
75 memcpy(buf, data, n);
76 acl_myfree(data);
77
78 if (mbedtls_des3_crypt_cbc(&ctx, MBEDTLS_DES_DECRYPT, n, iv, buf, buf) != 0)
79 {
80 acl_myfree(buf);
81 acl_msg_error("%s: des3_crypt_cbc error!", myname);
82 printf("n: %d\n", (int) n);
83 return NULL;
84 }
85
86 return (char*) buf;
87}

Callers 1

load_mail_dbMethod · 0.85

Calls 3

acl_msg_errorFunction · 0.85
acl_base64_decodeFunction · 0.85
memcpyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…