Skip to content

Commit

Permalink
Rebase; remove py2 support; support minimal build
Browse files Browse the repository at this point in the history
  • Loading branch information
Jörn Heissler committed May 16, 2021
1 parent 8bba82f commit 05562a8
Show file tree
Hide file tree
Showing 11 changed files with 502 additions and 122 deletions.
4 changes: 3 additions & 1 deletion src/bindings/crypto_core_ristretto255.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2020 Donald Stufft and individual contributors
/* Copyright 2021 Donald Stufft and individual contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,8 @@
* limitations under the License.
*/

static const int PYNACL_HAS_CRYPTO_CORE_RISTRETTO25519;

size_t crypto_core_ristretto255_scalarbytes(void);
size_t crypto_core_ristretto255_nonreducedscalarbytes(void);

Expand Down
4 changes: 3 additions & 1 deletion src/bindings/crypto_scalarmult_ristretto255.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2020 Donald Stufft and individual contributors
/* Copyright 2021 Donald Stufft and individual contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,8 @@
* limitations under the License.
*/

static const int PYNACL_HAS_CRYPTO_SCALARMULT_RISTRETTO25519;

size_t crypto_scalarmult_ristretto255_bytes(void);
size_t crypto_scalarmult_ristretto255_scalarbytes(void);

Expand Down
41 changes: 41 additions & 0 deletions src/bindings/minimal/crypto_core_ristretto255.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* Copyright 2021 Donald Stufft and individual contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifdef SODIUM_LIBRARY_MINIMAL
static const int PYNACL_HAS_CRYPTO_CORE_RISTRETTO25519 = 0;

size_t (*crypto_core_ristretto255_scalarbytes)(void) = NULL;
size_t (*crypto_core_ristretto255_nonreducedscalarbytes)(void) = NULL;

void (*crypto_core_ristretto255_scalar_add)(unsigned char *, const unsigned char *, const unsigned char *) = NULL;
void (*crypto_core_ristretto255_scalar_complement)(unsigned char *, const unsigned char *) = NULL;
int (*crypto_core_ristretto255_scalar_invert)(unsigned char *, const unsigned char *) = NULL;
void (*crypto_core_ristretto255_scalar_mul)(unsigned char *, const unsigned char *, const unsigned char *) = NULL;
void (*crypto_core_ristretto255_scalar_negate)(unsigned char *, const unsigned char *) = NULL;
void (*crypto_core_ristretto255_scalar_random)(unsigned char *) = NULL;
void (*crypto_core_ristretto255_scalar_reduce)(unsigned char *, const unsigned char *) = NULL;
void (*crypto_core_ristretto255_scalar_sub)(unsigned char *, const unsigned char *, const unsigned char *) = NULL;

size_t (*crypto_core_ristretto255_bytes)(void) = NULL;
size_t (*crypto_core_ristretto255_hashbytes)(void) = NULL;

int (*crypto_core_ristretto255_add)(unsigned char *, const unsigned char *, const unsigned char *) = NULL;
int (*crypto_core_ristretto255_from_hash)(unsigned char *, const unsigned char *) = NULL;
int (*crypto_core_ristretto255_is_valid_point)(const unsigned char *) = NULL;
int (*crypto_core_ristretto255_sub)(unsigned char *, const unsigned char *, const unsigned char *) = NULL;
void (*crypto_core_ristretto255_random)(unsigned char *) = NULL;
#else
static const int PYNACL_HAS_CRYPTO_CORE_RISTRETTO25519 = 1;
#endif
26 changes: 26 additions & 0 deletions src/bindings/minimal/crypto_scalarmult_ristretto255.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* Copyright 2021 Donald Stufft and individual contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifdef SODIUM_LIBRARY_MINIMAL
static const int PYNACL_HAS_CRYPTO_SCALARMULT_RISTRETTO25519 = 0;

size_t (*crypto_scalarmult_ristretto255_bytes)(void) = NULL;
size_t (*crypto_scalarmult_ristretto255_scalarbytes)(void) = NULL;

int (*crypto_scalarmult_ristretto255_base)(unsigned char *q, const unsigned char *n) = NULL;
int (*crypto_scalarmult_ristretto255)(unsigned char *q, const unsigned char *n, const unsigned char *p) = NULL;
#else
static const int PYNACL_HAS_CRYPTO_SCALARMULT_RISTRETTO25519 = 1;
#endif
4 changes: 4 additions & 0 deletions src/nacl/bindings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
crypto_core_ristretto255_scalar_reduce,
crypto_core_ristretto255_scalar_sub,
crypto_core_ristretto255_sub,
has_crypto_core_ristretto25519,
)
from nacl.bindings.crypto_generichash import (
crypto_generichash_BYTES,
Expand Down Expand Up @@ -199,6 +200,7 @@
crypto_scalarmult_ristretto255_BYTES,
crypto_scalarmult_ristretto255_SCALAR_BYTES,
crypto_scalarmult_ristretto255_base,
has_crypto_scalarmult_ristretto25519,
)
from nacl.bindings.crypto_secretbox import (
crypto_secretbox,
Expand Down Expand Up @@ -323,6 +325,7 @@
"crypto_core_ed25519_scalar_sub",
"crypto_core_ed25519_scalar_mul",
"crypto_core_ed25519_scalar_reduce",
"has_crypto_core_ristretto25519",
"crypto_core_ristretto255_SCALAR_BYTES",
"crypto_core_ristretto255_NONREDUCED_SCALAR_BYTES",
"crypto_core_ristretto255_GROUP_ORDER",
Expand Down Expand Up @@ -379,6 +382,7 @@
"crypto_scalarmult_ed25519_base",
"crypto_scalarmult_ed25519_noclamp",
"crypto_scalarmult_ed25519_base_noclamp",
"has_crypto_scalarmult_ristretto25519",
"crypto_scalarmult_ristretto255_BYTES",
"crypto_scalarmult_ristretto255_SCALAR_BYTES",
"crypto_scalarmult_ristretto255_base",
Expand Down
Loading

0 comments on commit 05562a8

Please sign in to comment.