Switch to HMAC-BLAKE2s

This commit is contained in:
Tony Garnock-Jones 2023-02-06 16:31:04 +01:00
parent d43d78daaf
commit 02acdbeb03
8 changed files with 20 additions and 19 deletions

View File

@ -1,6 +1,6 @@
__ignored__ := $(shell ./setup.sh)
PACKAGES=syndicate syndicate-examples syndicate-msd syndicate-noise
PACKAGES=syndicate syndicate-examples syndicate-msd
COLLECTS=syndicate syndicate-examples
all: setup

View File

@ -12,7 +12,7 @@
(require (only-in file/sha1 hex-string->bytes))
(define me (symbol->string (strong-gensym 'user)))
(define ref (SturdyRef "syndicate" '() (hex-string->bytes "a6480df5306611ddd0d3882b546e1977")))
(define ref (SturdyRef "syndicate" '() (hex-string->bytes "6617ec85e29cee1eb4f2085aa1fdedff")))
(standard-actor-system (ds)
(define conn-facet this-facet)

View File

@ -1,7 +0,0 @@
#lang setup/infotab
;;; SPDX-License-Identifier: LGPL-3.0-or-later
;;; SPDX-FileCopyrightText: Copyright © 2023 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
(define collection 'multi)
(define deps '("base" "syndicate" "noise-protocol"))
(define build-deps '("libsodium"))

View File

@ -5,7 +5,7 @@
(provide run-tcp-client-relay
run-tcp-server-relay)
(require (only-in sha bytes->hex-string))
(require (only-in file/sha1 bytes->hex-string))
(require syndicate/distributed/gatekeeper)
(require syndicate/drivers/tcp)
(require syndicate/relay)

View File

@ -8,10 +8,11 @@
"base"
"data-lib"
"auxiliary-macro-context"
"data-lib"
"libb2"
"noise-protocol"
"preserves"
"sha"
"struct-defaults"
"web-server-lib"
@ -27,7 +28,11 @@
))
(define build-deps '("rackunit-lib" "at-exp-lib"))
(define build-deps '(
"at-exp-lib"
"libsodium"
"rackunit-lib"
))
(define pre-install-collection "private/install.rkt")

View File

@ -21,7 +21,8 @@
(all-from-out "schemas/sturdy.rkt"))
(require racket/match)
(require (only-in sha hmac-sha256))
(require (only-in libb2 blake2s BLAKE2S_BLOCKLEN))
(require (only-in noise-protocol/hmac make-hmac))
(require (only-in racket/random crypto-random-bytes))
(require preserves)
(require preserves-schema)
@ -45,8 +46,10 @@
#:read-syntax? #f
#:decode-embedded embedded-not-allowed))
(define hmac-BLAKE2s (make-hmac blake2s BLAKE2S_BLOCKLEN))
(define (signature key data)
(subbytes (hmac-sha256 key data) 0 KEY_LENGTH))
(subbytes (hmac-BLAKE2s key data) 0 KEY_LENGTH))
(define (mint oid key)
(SturdyRef oid '() (signature key (sturdy-encode oid))))

View File

@ -11,18 +11,18 @@
(define s0 (mint "test" #""))
(check-equal? s0 (SturdyRef "test" '() #"J\270\253\306N\365\2240\303\206\324\2G\306m\377"))
(check-equal? s0 (SturdyRef "test" '() #">\330w\326\3r{\216U`j\24\376\203\242\360"))
(check-true (SturdyRef-valid? s0 #""))
(define s1 (attenuate-sturdy s0 'a 'b 'c))
(check-equal? s1 (SturdyRef "test" '(a b c) #"oO\243\334\366aW6\5\303<\314St\275\226"))
(check-equal? s1 (SturdyRef "test" '(a b c) #"\261\220\327\363X\317\202\251&\367\3734*\355\333\324"))
(check-true (SturdyRef-valid? s1 #""))
(check-false (SturdyRef-valid?
(SturdyRef "test" '(a b c) #"pO\243\334\366aW6\5\303<\314St\275\226")
(SturdyRef "test" '(a b c) #"\261\220\327\363X\317\202\251&\367\3734?\355\333\324")
#""))
(check-false (SturdyRef-valid?
(SturdyRef "test" '(a c b) #"oO\243\334\366aW6\5\303<\314St\275\226")
(SturdyRef "test" '(a c b) #"\261\220\327\363X\317\202\251&\367\3734*\355\333\324")
#""))
)