libidav/crypto.c

changeset 691
48ec0ab17011
parent 690
ce253cfb9127
child 692
56b66fe2b4f5
equal deleted inserted replaced
690:ce253cfb9127 691:48ec0ab17011
1237 ULONG outlen = 0; 1237 ULONG outlen = 0;
1238 char *out = malloc(outalloc); 1238 char *out = malloc(outalloc);
1239 1239
1240 // encrypt 1240 // encrypt
1241 int flags = 0; 1241 int flags = 0;
1242 if(inlen % 16 != 0) { 1242 if(inlen % 16 != 0 || enc->end) {
1243 enc->end = 1;
1244 }
1245 if(enc->end) {
1243 flags = BCRYPT_BLOCK_PADDING; 1246 flags = BCRYPT_BLOCK_PADDING;
1244 enc->end = 1;
1245 } 1247 }
1246 if(BCryptEncrypt(enc->ctx.hKey, in, inlen, NULL, enc->ctx.pbIV, 16, out, outalloc, &outlen, flags)) { 1248 if(BCryptEncrypt(enc->ctx.hKey, in, inlen, NULL, enc->ctx.pbIV, 16, out, outalloc, &outlen, flags)) {
1247 fprintf(stderr, "Error: BCryptEncrypt failed\n"); 1249 fprintf(stderr, "Error: BCryptEncrypt failed\n");
1248 } 1250 }
1249 1251

mercurial