305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
-
+
-
+
|
* Sets result to message digest or an error message.
*
*-------------------------------------------------------------------
*/
int DigestFinalize(Tcl_Interp *interp, DigestState *statePtr, Tcl_Obj **resultObj) {
unsigned char md_buf[EVP_MAX_MD_SIZE];
unsigned int ulen;
int res = 0, md_len = 0;
int res = 0, md_len = 0, type = statePtr->format & 0xFF0;
dprintf("Called");
/* Finalize cryptography function and get result */
switch(statePtr->format & 0xFF0) {
switch(type) {
case TYPE_MD:
if (!(statePtr->format & IS_XOF)) {
res = EVP_DigestFinal_ex(statePtr->ctx, md_buf, &ulen);
md_len = (int) ulen;
} else {
res = EVP_DigestFinalXOF(statePtr->ctx, md_buf, (size_t) EVP_MAX_MD_SIZE);
md_len = EVP_MAX_MD_SIZE;
|
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
|
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
|
-
+
-
+
-
+
-
+
-
+
-
+
|
* TCL_OK or TCL_ERROR
*
* Side effects:
* Sets result to message digest or error message
*
*-------------------------------------------------------------------
*/
#define validate_argc(objc, objv) { \
#define VALIDATE_ARGC(objc, objv) { \
if (objc != 2) { \
Tcl_WrongNumArgs(interp, 1, objv, "data"); \
return TCL_ERROR; \
} \
}
int MD4ObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) {
validate_argc(objc, objv);
VALIDATE_ARGC(objc, objv);
return DigestDataHandler(interp, objv[1], EVP_md4(), NULL, HEX_FORMAT | TYPE_MD, NULL, NULL);
}
int MD5ObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) {
validate_argc(objc, objv);
VALIDATE_ARGC(objc, objv);
return DigestDataHandler(interp, objv[1], EVP_md5(), NULL, HEX_FORMAT | TYPE_MD, NULL, NULL);
}
int SHA1ObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) {
validate_argc(objc, objv);
VALIDATE_ARGC(objc, objv);
return DigestDataHandler(interp, objv[1], EVP_sha1(), NULL, HEX_FORMAT | TYPE_MD, NULL, NULL);
}
int SHA256ObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) {
validate_argc(objc, objv);
VALIDATE_ARGC(objc, objv);
return DigestDataHandler(interp, objv[1], EVP_sha256(), NULL, HEX_FORMAT | TYPE_MD, NULL, NULL);
}
int SHA512ObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) {
validate_argc(objc, objv);
VALIDATE_ARGC(objc, objv);
return DigestDataHandler(interp, objv[1], EVP_sha512(), NULL, HEX_FORMAT | TYPE_MD, NULL, NULL);
}
/*
*-------------------------------------------------------------------
*
* Tls_DigestCommands --
|