Overview
Comment: | More work on an internal signing function |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
8e2b1497b349bec0263a154fb5bba390 |
User & Date: | rkeene on 2018-06-30 13:13:28 |
Other Links: | manifest | tags |
Context
2018-07-01
| ||
20:06 | Added patch to allow deriving the public key component from a secret key check-in: f08c39c4fe user: rkeene tags: trunk | |
2018-06-30
| ||
13:13 | More work on an internal signing function check-in: 8e2b1497b3 user: rkeene tags: trunk | |
04:17 | Shaped up Makefile a bit check-in: a487f5ba86 user: rkeene tags: trunk | |
Changes
Modified .fossil-settings/ignore-glob from [eb5697f7a1] to [bc53e55637].
1 2 3 4 5 6 7 8 | nano.so Makefile pkgIndex.tcl aclocal.m4 config.guess config.sub configure install-sh | > | 1 2 3 4 5 6 7 8 9 | nano.so nano.o Makefile pkgIndex.tcl aclocal.m4 config.guess config.sub configure install-sh |
︙ | ︙ |
Modified Makefile.in from [2ff36901f0] to [7a0a4eadd8].
1 2 | CC := @CC@ CFLAGS := @CFLAGS@ @SHOBJFLAGS@ | | | 1 2 3 4 5 6 7 8 9 10 | CC := @CC@ CFLAGS := @CFLAGS@ @SHOBJFLAGS@ CPPFLAGS := -I./tweetnacl/ -I./blake2b/ -DSUPERCOP=1 @CPPFLAGS@ @SHOBJCPPFLAGS@ LDFLAGS := @LDFLAGS@ LIBS := @LIBS@ SHOBJLDFLAGS := @SHOBJLDFLAGS@ export CC CFLAGS CPPFLAGS all: @EXTENSION_TARGET@ |
︙ | ︙ |
Added build/test/test.tcl version [9220486097].
> > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 | #! /usr/bin/env tclsh lappend auto_path [file join [file dirname [info script]] .. ..] package require nano set key [binary decode hex 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000] puts "Key Length: [string length $key]" set signed [binary encode hex [::nano::internal::sign "" $key]] puts $signed |
Modified nano.c from [7748433431] to [a802819e09].
1 2 3 4 5 6 7 8 9 | #include <tcl.h> #include <stdint.h> #if 0 #include <sys/random.h> void randombytes(uint8_t *buffer, uint64_t length) { ssize_t gr_ret; | > > | 1 2 3 4 5 6 7 8 9 10 11 | #include <tcl.h> #include <stdint.h> #include <limits.h> #include "tweetnacl.h" #if 0 #include <sys/random.h> void randombytes(uint8_t *buffer, uint64_t length) { ssize_t gr_ret; |
︙ | ︙ | |||
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | length -= current_length; } return; } #endif void randombytes(uint8_t *buffer, uint64_t length) { while (length > 0) { buffer[length - 1] = (length % 256); length--; } return; } static int nano_sign(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { return(TCL_OK); } int Nano_Init(Tcl_Interp *interp) { #ifdef USE_TCL_STUBS const char *tclInitStubs_ret; /* Initialize Stubs */ tclInitStubs_ret = Tcl_InitStubs(interp, TCL_PATCH_LEVEL, 0); if (!tclInitStubs_ret) { return(TCL_ERROR); } #endif Tcl_CreateObjCommand(interp, "::nano::internal::sign", nano_sign, NULL, NULL); return(TCL_OK); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | length -= current_length; } return; } #endif /* * XXX:TODO: NOT RANDOM: For testing only */ void randombytes(uint8_t *buffer, uint64_t length) { while (length > 0) { buffer[length - 1] = (length % 256); length--; } return; } static int nano_sign(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { int cs_ret; unsigned char *signature, *data, *secret_key; unsigned long long signature_length; int data_length, secret_key_length; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "data secretKey"); return(TCL_ERROR); } data = Tcl_GetByteArrayFromObj(objv[1], &data_length); secret_key = Tcl_GetByteArrayFromObj(objv[2], &secret_key_length); if (secret_key_length != crypto_sign_SECRETKEYBYTES) { Tcl_SetResult(interp, "Secret key is not the right size", NULL); return(TCL_ERROR); } signature_length = data_length + crypto_sign_BYTES; if (signature_length >= UINT_MAX) { Tcl_SetResult(interp, "Input message too long", NULL); return(TCL_ERROR); } signature = (unsigned char *) Tcl_AttemptAlloc(signature_length); if (!signature) { Tcl_SetResult(interp, "Unable to allocate memory", NULL); return(TCL_ERROR); } cs_ret = crypto_sign(signature, &signature_length, data, data_length, secret_key); if (cs_ret != 0) { Tcl_SetResult(interp, "crypto_sign failed", NULL); return(TCL_ERROR); } Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(signature, signature_length)); return(TCL_OK); /* NOTREACH */ clientData = clientData; } int Nano_Init(Tcl_Interp *interp) { #ifdef USE_TCL_STUBS const char *tclInitStubs_ret; /* Initialize Stubs */ tclInitStubs_ret = Tcl_InitStubs(interp, TCL_PATCH_LEVEL, 0); if (!tclInitStubs_ret) { return(TCL_ERROR); } #endif Tcl_CreateObjCommand(interp, "::nano::internal::sign", nano_sign, NULL, NULL); return(TCL_OK); } |