| 47 | } |
| 48 | |
| 49 | char* 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 | } |
no test coverage detected
searching dependent graphs…