Overview
Comment: | Added untested argon2-based key derivation |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | monocypher |
Files: | files | file ages | folders |
SHA3-256: |
3872cde7b27ee1634274c6629916ef57 |
User & Date: | rkeene on 2019-01-10 09:45:20 |
Other Links: | branch diff | manifest | tags |
Context
2019-01-10
| ||
09:55 | Minor cleanup check-in: 78b6dd6345 user: rkeene tags: monocypher | |
09:45 | Added untested argon2-based key derivation check-in: 3872cde7b2 user: rkeene tags: monocypher | |
09:18 | Added more Argon2 files, and try to build with as few public symbols as possible check-in: 489a16edb6 user: rkeene tags: monocypher | |
Changes
Modified nano.c from [3e25e24c1a] to [2ca35184b8].
︙ | ︙ | |||
18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #define NANO_SECRET_KEY_LENGTH 32 #define NANO_PUBLIC_KEY_LENGTH 32 #define NANO_BLOCK_HASH_LENGTH 32 #define NANO_BLOCK_SIGNATURE_LENGTH 64 #define NANO_WORK_VALUE_LENGTH 8 #define NANO_WORK_HASH_LENGTH 8 #define NANO_WORK_DEFAULT_MIN 0xffffffc000000000LLU #define TclNano_AttemptAlloc(x) ((void *) Tcl_AttemptAlloc(x)) #define TclNano_Free(x) Tcl_Free((char *) x) #define TclNano_SetIntVar(interp, name, intValue) \ tclobj_ret = Tcl_SetVar2Ex(interp, name, NULL, Tcl_NewIntObj(intValue), TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG); \ if (!tclobj_ret) { \ return(TCL_ERROR); \ | > > > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #define NANO_SECRET_KEY_LENGTH 32 #define NANO_PUBLIC_KEY_LENGTH 32 #define NANO_BLOCK_HASH_LENGTH 32 #define NANO_BLOCK_SIGNATURE_LENGTH 64 #define NANO_WORK_VALUE_LENGTH 8 #define NANO_WORK_HASH_LENGTH 8 #define NANO_WORK_DEFAULT_MIN 0xffffffc000000000LLU #define NANO_KDF_ARGON2_MEMORY 64 * 1024 #define NANO_KDF_ARGON2_TIMING 1 #define NANO_KDF_ARGON2_THREADS 1 #define TclNano_AttemptAlloc(x) ((void *) Tcl_AttemptAlloc(x)) #define TclNano_Free(x) Tcl_Free((char *) x) #define TclNano_SetIntVar(interp, name, intValue) \ tclobj_ret = Tcl_SetVar2Ex(interp, name, NULL, Tcl_NewIntObj(intValue), TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG); \ if (!tclobj_ret) { \ return(TCL_ERROR); \ |
︙ | ︙ | |||
278 279 280 281 282 283 284 | return(TCL_OK); /* NOTREACH */ clientData = clientData; } | < > | > > | | | | < < < < | | | < < < < | < < | | | | > > | > | > > > < | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | return(TCL_OK); /* NOTREACH */ clientData = clientData; } static int nano_tcl_derive_key_from_password(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { void *password, *salt; int password_length, salt_length; unsigned char result[32]; int hash_ret; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "password salt"); return(TCL_ERROR); } password = Tcl_GetByteArrayFromObj(objv[1], &password_length); salt = Tcl_GetByteArrayFromObj(objv[2], &salt_length); hash_ret = argon2_hash(NANO_KDF_ARGON2_TIMING, NANO_KDF_ARGON2_MEMORY, 1, password, password_length, salt, salt_length, result, sizeof(result), NULL, 0, Argon2_d, 0x10); if (hash_ret != ARGON2_OK) { Tcl_SetResult(interp, (char *) argon2_error_message(hash_ret), NULL); return(TCL_ERROR); } Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(result, sizeof(result))); return(TCL_OK); /* NOTREACH */ clientData = clientData; } static int nano_tcl_hash_data(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { unsigned char *data, result[NANO_BLOCK_SIGNATURE_LENGTH]; int tgifo_ret; int data_length, result_length; if (objc < 2 || objc > 3) { |
︙ | ︙ | |||
605 606 607 608 609 610 611 | TclNano_CreateObjCommand(interp, "::nano::internal::selfTest", nano_tcl_self_test); TclNano_CreateObjCommand(interp, "::nano::internal::generateKey", nano_tcl_generate_keypair); TclNano_CreateObjCommand(interp, "::nano::internal::generateSeed", nano_tcl_generate_seed); TclNano_CreateObjCommand(interp, "::nano::internal::publicKey", nano_tcl_secret_key_to_public_key); TclNano_CreateObjCommand(interp, "::nano::internal::signDetached", nano_tcl_sign_detached); TclNano_CreateObjCommand(interp, "::nano::internal::verifyDetached", nano_tcl_verify_detached); TclNano_CreateObjCommand(interp, "::nano::internal::hashData", nano_tcl_hash_data); | | | 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | TclNano_CreateObjCommand(interp, "::nano::internal::selfTest", nano_tcl_self_test); TclNano_CreateObjCommand(interp, "::nano::internal::generateKey", nano_tcl_generate_keypair); TclNano_CreateObjCommand(interp, "::nano::internal::generateSeed", nano_tcl_generate_seed); TclNano_CreateObjCommand(interp, "::nano::internal::publicKey", nano_tcl_secret_key_to_public_key); TclNano_CreateObjCommand(interp, "::nano::internal::signDetached", nano_tcl_sign_detached); TclNano_CreateObjCommand(interp, "::nano::internal::verifyDetached", nano_tcl_verify_detached); TclNano_CreateObjCommand(interp, "::nano::internal::hashData", nano_tcl_hash_data); TclNano_CreateObjCommand(interp, "::nano::internal::deriveKeyFromPassword", nano_tcl_derive_key_from_password); TclNano_CreateObjCommand(interp, "::nano::internal::validateWork", nano_tcl_validate_work); TclNano_CreateObjCommand(interp, "::nano::internal::generateWork", nano_tcl_generate_work); TclNano_CreateObjCommand(interp, "::nano::internal::randomBytes", nano_tcl_random_bytes); TclNano_Eval(interp, nanoInitScript); TclNano_PkgProvide(interp, "nano", PACKAGE_VERSION); return(TCL_OK); } |