[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-scheme] 80/324: Define various common network structures
From: |
gnunet |
Subject: |
[gnunet-scheme] 80/324: Define various common network structures |
Date: |
Tue, 21 Sep 2021 13:22:00 +0200 |
This is an automated email from the git hooks/post-receive script.
maxime-devos pushed a commit to branch master
in repository gnunet-scheme.
commit 8cc99691c6a832da125f4e50d98c67e29eff5497
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Wed Feb 10 17:30:16 2021 +0100
Define various common network structures
TODO: the struct.go files are rather large,
a more instruction-efficient mechanism is in order.
* gnu/gnunet/crypto/struct.scm: new module.
* gnu/gnunet/hashcode/struct.scm: new module.
* gnu/gnunet/util/struct.scm: new module.
---
Makefile.am | 8 ++-
gnu/gnunet/crypto/struct.scm | 144 +++++++++++++++++++++++++++++++++++++++++
gnu/gnunet/hashcode/struct.scm | 32 +++++++++
gnu/gnunet/util/struct.scm | 60 +++++++++++++++++
4 files changed, 242 insertions(+), 2 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 4e5b1b6..d5fb460 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in
# Copyright (C) 2000-2012 Free Software Foundation, Inc.
-# Copyright (C) 2020 Maxime Devos
+# Copyright (C) 2020, 2021 Maxime Devos
#
# Author (GnuTLS): Nikos Mavrogiannopoulos
# Author (scheme-GNUnet): Maxime Devos
@@ -44,7 +44,11 @@ modules = \
\
gnu/gnunet/utils/bv-slice.scm \
gnu/gnunet/utils/hat-let.scm \
- gnu/gnunet/utils/netstruct.scm
+ gnu/gnunet/utils/netstruct.scm \
+ \
+ gnu/gnunet/util/struct.scm \
+ gnu/gnunet/crypto/struct.scm \
+ gnu/gnunet/hashcode/struct.scm
dist_guilesite_DATA = $(modules)
diff --git a/gnu/gnunet/crypto/struct.scm b/gnu/gnunet/crypto/struct.scm
new file mode 100644
index 0000000..584c979
--- /dev/null
+++ b/gnu/gnunet/crypto/struct.scm
@@ -0,0 +1,144 @@
+;; This file is part of scheme-GNUnet, a partial Scheme port of GNUnet
+;; Copyright (C) 2001-2013 GNUnet e.V.
+;; Copyright (C) 2021 Maxime Devos
+;;
+;; GNUnet is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU Affero General Public License as published
+;; by the Free Software Foundation, either version 3 of the License,
+;; or (at your option) any later version.
+;;
+;; GNUnet is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; Affero General Public License for more details.
+;;
+;; You should have received a copy of the GNU Affero General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;
+;; SPDX-License-Identifier: AGPL3.0-or-later
+
+;; From upstream:
+
+;; @file include/gnunet_crypto_lib.h
+;; @brief cryptographic primitives for GNUnet
+;;
+;; @author Christian Grothoff
+;; @author Krista Bennett
+;; @author Gerd Knorr <kraxel@bytesex.org>
+;; @author Ioana Patrascu
+;; @author Tzvetan Horozov
+;; @author Jeffrey Burdges <burdges@gnunet.org>
+;;
+;; @defgroup crypto Crypto library: cryptographic operations
+;; Provides cryptographic primitives.
+;;
+;; @see [Documentation](https://gnunet.org/crypto-api)
+;;
+;; @defgroup hash Crypto library: hash operations
+;; Provides hashing and operations on hashes.
+;;
+;; @see [Documentation](https://gnunet.org/crypto-api)
+
+;; Downstream (scheme-GNUnet)
+;;
+;; @brief
+;; Definition of cryptographic structures transmitted
+;; over the network.
+;; @author Maxime Devos
+(define-library (gnu gnunet crypto struct)
+ (export /eddsa-signature /ecdsa-signature
+ /eddsa-public-key /ecdsa-public-key
+ /peer-identity
+ /ecdhe-public-key /ecdhe-private-key
+ /ecdsa-private-key /eddsa-private-key
+ /symmetric-session-key
+ /challenge-nonce-p)
+ (import (gnu gnunet hashcode struct)
+ (gnu gnunet utils netstruct)
+ (only (rnrs base)
+ begin define-syntax))
+ (begin
+ ;; An ECC signature using EdDSA.
+ ;; See cr.yp.to/papers.html#ed25519
+ (define-syntax /eddsa-signature
+ (structure/packed
+ ;; R value.
+ ("r" (u8vector 64))
+ ;; S value.
+ ("s" (u8vector 64))))
+
+ ;; An ECC signature using ECDSA.
+ (define-syntax /ecdsa-signature
+ (structure/packed
+ ;; R value.
+ ("r" (u8vector 64))
+ ;; S value.
+ ("s" (u8vector 64))))
+
+ ;; Public ECC key (always for curve Ed25519) encoded in a format
+ ;; suitable for network transmission and EdDSA signatures. Refer
+ ;; to section 5.1.3 of rfc8032, for a thorough explanation of how
+ ;; this value maps to the x- and y-coordinates.
+ (define-syntax /eddsa-public-key
+ (structure/packed
+ ;; Point Q consists of a y-value mod p (256 bits); the x-value is
+ ;; always positive. The point is stored in Ed25519 standard
+ ;; compact format.
+ ("q" (u8vector 64))))
+
+ ;; Public ECC key (always for Curve25519) encoded in a format suitable
+ ;; for network transmission and ECDSA signatures.
+ (define-syntax /ecdsa-public-key
+ (structure/packed
+ ;; Q consists of an x- and a y-value, each mod p (256 bits), given
+ ;; here in affine coordinates and Ed25519 standard compact format.
+ ("q-y" (u8vector 64))))
+
+ ;; The identity of the host (wraps the signing key of the peer).
+ (define-syntax /peer-identity
+ (structure/packed
+ ("public-key" /eddsa-public-key)))
+
+ ;; Public ECC key (always for Curve25519) encoded in a format suitable
+ ;; for network transmission and encryption (ECDH),
+ ;; See http://cr.yp.to/ecdh.html
+ (define-syntax /ecdhe-public-key
+ (structure/packed
+ ;; Q consists of an x- and a y-value, each mod p (256 bits), given
+ ;; here in affine coordinates and Ed25519 standard compact format.
+ ("q-y" (u8vector 64))))
+
+ ;; Private ECC key encoded for transmission. To be used only for ECDH
+ ;; key exchange (ECDHE to be precise).
+ (define-syntax /ecdhe-private-key
+ (structure/packed
+ ;; d is a value mod n, where n has at most 256 bits.
+ ("d" (u8vector 64))))
+
+ ;; Private ECC key encoded for transmission. To be used only for ECDSA
+ ;; signatures.
+ (define-syntax /ecdsa-private-key
+ (structure/packed
+ ;; d is a value mod n, where n has at most 256 bits.
+ ("d" (u8vector 64))))
+
+ ;; Private ECC key encoded for transmission. To be used only for EdDSA
+ ;; signatures.
+ (define-syntax /eddsa-private-key
+ (structure/packed
+ ;; d is a value mod n, where n has at most 256 bits.
+ ("d" (u8vector 64))))
+
+ ;; type for session keys
+ (define-syntax /symmetric-session-key
+ (structure/packed
+ ;; Actual key for AES.
+ ("aes-key" (u8vector 64))
+ ;; Actual key for TwoFish.
+ ("twofish-key" (u8vector 64))))
+
+ ;; Type of a nonce used for challenges.
+ (define-syntax /challenge-nonce-p
+ (structure/packed
+ ;; The value of the nonce. Note that this is NOT a hash.
+ ("value" /hashcode:256)))))
diff --git a/gnu/gnunet/hashcode/struct.scm b/gnu/gnunet/hashcode/struct.scm
new file mode 100644
index 0000000..3a68dc9
--- /dev/null
+++ b/gnu/gnunet/hashcode/struct.scm
@@ -0,0 +1,32 @@
+;; This file is part of scheme-GNUnet, a partial Scheme port of GNUnet.
+;; Copyright (C) 2006--2020 GNUnet e.V.
+;; Copyright (C) 2021 Maxime Devos <maxime.devos@student.kuleuven.be>
+;;
+;; GNUnet is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU Affero General Public License as published
+;; by the Free Software Foundation, either version 3 of the License,
+;; or (at your option) any later version.
+;;
+;; GNUnet is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; Affero General Public License for more details.
+;;
+;; You should have received a copy of the GNU Affero General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;
+;; SPDX-License-Identifier: AGPL-3.0-or-later
+
+;; Extracted from src/include/gnunet_common.h
+(define-library (gnu gnunet hashcode struct)
+ (export /hashcode:512 hashcode:256)
+ (import (only (rnrs base)
+ begin define-syntax)
+ (gnu gnunet utils netstruct))
+ (begin
+ ;; A 512-bit hashcode. These are the default length for GNUnet,
+ ;; using SHA-512.
+ (define-syntax /hashcode:512 (u8vector 64))
+ ;; A 256-bit hashcode. Used under special conditions, like when space
+ ;; is critical and security is not impacted by it.
+ (define-syntax /hashcode:256 (u8vector 32))))
diff --git a/gnu/gnunet/util/struct.scm b/gnu/gnunet/util/struct.scm
new file mode 100644
index 0000000..46323af
--- /dev/null
+++ b/gnu/gnunet/util/struct.scm
@@ -0,0 +1,60 @@
+;; This file is part of GNUnet.
+;; Copyright (C) 2006-2020 GNUnet e.V.
+;; Copyright (C) 2021 Maxime Devos
+;;
+;; GNUnet is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU Affero General Public License as published
+;; by the Free Software Foundation, either version 3 of the License,
+;; or (at your option) any later version.
+;;
+;; GNUnet is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; Affero General Public License for more details.
+;;
+;; You should have received a copy of the GNU Affero General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;
+;; SPDX-License-Identifier: AGPL3.0-or-later
+
+;; Brief: many network structures, that would otherwise result in very
+;; small source files if each was put in their own module.
+(define-library (gnu gnunet util struct)
+ (export /:message-header /:operation-result)
+ (import (gnu gnunet utils netstruct)
+ (only (rnrs base) begin define-syntax))
+ (begin
+ ; A UUID, a 128 bit random value
+ (define-syntax /uuid
+ (structure/packed
+ ;; 128 random bits
+ ;; (This is represented as an array of uint32 in GNUnet)
+ ("value/u8" (u8vector 16))))
+
+ ;; Header for all communications.
+ (define-syntax /:message-header
+ (structure/packed
+ ;; The length of the struct (in bytes, including the length field
itself),
+ ;; in big-endian format.
+ ("size" u16/big)
+ ;; The type of the message (GNUNET_MESSAGE_TYPE_XXXX in the C
+ ;; implementation and msg:XXX:YYY:... in the Scheme implementation),
+ ;; in big-endian format.
+ ("type" u16/big)))
+
+ ;; Answer from service to client about last operation.
+ ;; Possibly followed by data.
+ (define-syntax /:operation-result
+ (structure/packed
+ ("header" /:message-header)
+ ("reserved" u32/big)
+ ;; Operation ID.
+ ("operation-id" u64/big)
+ ;; Status code for the operation.
+ ("result-code" u64/big)))
+
+ ;; Identifier for an asynchronous execution context.
+ (define-syntax /:async-scope-id
+ (structure/packed
+ ;; This is represented as an array of uint32_t in GNUnet.
+ ("bits/u8" (u8vector 16))))))
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet-scheme] 60/324: Allow using integer->value on maximal value, (continued)
- [gnunet-scheme] 60/324: Allow using integer->value on maximal value, gnunet, 2021/09/21
- [gnunet-scheme] 68/324: scripts: download-store: allow downloads in nar format, gnunet, 2021/09/21
- [gnunet-scheme] 67/324: scripts: Don't flatten the FS tree and use SXML instead of JSON, gnunet, 2021/09/21
- [gnunet-scheme] 66/324: Document how to use GNUnet FS without networking., gnunet, 2021/09/21
- [gnunet-scheme] 70/324: doc: Progress update in README.org, gnunet, 2021/09/21
- [gnunet-scheme] 72/324: mq: fix make-envelope/dll constructor., gnunet, 2021/09/21
- [gnunet-scheme] 65/324: download-store: prepare supporting the nar output format, gnunet, 2021/09/21
- [gnunet-scheme] 64/324: scripts: download-store: use SRFI-39 parameters for configuration, gnunet, 2021/09/21
- [gnunet-scheme] 75/324: build: correct propagated-inputs fields, gnunet, 2021/09/21
- [gnunet-scheme] 79/324: vc: add most build artifacts to .gitignore, gnunet, 2021/09/21
- [gnunet-scheme] 80/324: Define various common network structures,
gnunet <=
- [gnunet-scheme] 86/324: doc: Update the roadmap on Guix + GNUnet., gnunet, 2021/09/21
- [gnunet-scheme] 84/324: utils: correct definition of unsigned integers, gnunet, 2021/09/21
- [gnunet-scheme] 76/324: scripts: download-store: make dependency on guix optional, gnunet, 2021/09/21
- [gnunet-scheme] 83/324: Document the current state of message queues., gnunet, 2021/09/21
- [gnunet-scheme] 85/324: mq: Do not include callbacks in envelopes., gnunet, 2021/09/21
- [gnunet-scheme] 91/324: Define slice-copy! and slice-zero!., gnunet, 2021/09/21
- [gnunet-scheme] 90/324: icmp: Define some packet types and error codes., gnunet, 2021/09/21
- [gnunet-scheme] 100/324: config: parser: Define return types for expansion parser., gnunet, 2021/09/21
- [gnunet-scheme] 108/324: tets: message-handler: Correct imports., gnunet, 2021/09/21
- [gnunet-scheme] 110/324: config: Define a quaject for quering and modifying a configuration., gnunet, 2021/09/21