Skip to content

Commit

Permalink
Make serde work in no-std
Browse files Browse the repository at this point in the history
  • Loading branch information
thomwiggers committed Nov 11, 2024
1 parent fce0249 commit 9412679
Show file tree
Hide file tree
Showing 27 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions pqcrypto-classicmceliece/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ categories = ["cryptography", "no-std"]
pqcrypto-internals = { path = "../pqcrypto-internals", version = "0.2.6" }
pqcrypto-traits = { path = "../pqcrypto-traits", version = "0.3.5", default-features = false }
libc = "0.2.0"
serde = { version = "1.0", features = ["derive"], optional = true }
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"], optional = true }
serde-big-array = { version = "0.5.1", optional = true }

[features]
default = ["avx2", "std"]
avx2 = ["std"]
std = ["pqcrypto-traits/std"]
serialization = ["serde", "serde-big-array"]
serialization = ["dep:serde", "dep:serde-big-array"]

[dev-dependencies]

Expand Down
4 changes: 2 additions & 2 deletions pqcrypto-falcon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ categories = ["cryptography", "no-std"]
pqcrypto-internals = { path = "../pqcrypto-internals", version = "0.2.6" }
pqcrypto-traits = { path = "../pqcrypto-traits", version = "0.3.5", default-features = false }
libc = "0.2.0"
serde = { version = "1.0", features = ["derive"], optional = true }
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"], optional = true }
serde-big-array = { version = "0.5.1", optional = true }

[features]
default = ["avx2", "neon", "std"]
avx2 = ["std"]
neon = ["std"]
std = ["pqcrypto-traits/std"]
serialization = ["serde", "serde-big-array"]
serialization = ["dep:serde", "dep:serde-big-array"]

[dev-dependencies]
rand = "0.8.5"
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-falcon/src/falcon1024.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ simple_struct!(
);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_FALCON1024_CLEAN_CRYPTO_BYTES],
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-falcon/src/falcon512.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ simple_struct!(
);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_FALCON512_CLEAN_CRYPTO_BYTES],
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-falcon/src/falconpadded1024.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ simple_struct!(
);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_FALCONPADDED1024_CLEAN_CRYPTO_BYTES],
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-falcon/src/falconpadded512.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ simple_struct!(
);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_FALCONPADDED512_CLEAN_CRYPTO_BYTES],
Expand Down
4 changes: 2 additions & 2 deletions pqcrypto-hqc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ categories = ["cryptography", "no-std"]
pqcrypto-internals = { path = "../pqcrypto-internals", version = "0.2.6" }
pqcrypto-traits = { path = "../pqcrypto-traits", version = "0.3.5", default-features = false }
libc = "0.2.0"
serde = { version = "1.0", features = ["derive"], optional = true }
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"], optional = true }
serde-big-array = { version = "0.5.1", optional = true }

[features]
default = ["std"]
std = ["pqcrypto-traits/std"]
serialization = ["serde", "serde-big-array"]
serialization = ["dep:serde", "dep:serde-big-array"]

[dev-dependencies]

Expand Down
4 changes: 2 additions & 2 deletions pqcrypto-mldsa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ categories = ["cryptography", "no-std"]
pqcrypto-internals = { path = "../pqcrypto-internals", version = "0.2.6" }
pqcrypto-traits = { path = "../pqcrypto-traits", version = "0.3.5", default-features = false }
libc = "0.2.0"
serde = { version = "1.0", features = ["derive"], optional = true }
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"], optional = true }
serde-big-array = { version = "0.5.1", optional = true }
paste = "1.0"

Expand All @@ -24,7 +24,7 @@ default = ["avx2", "neon", "std"]
avx2 = ["std"]
neon = ["std"]
std = ["pqcrypto-traits/std"]
serialization = ["serde", "serde-big-array"]
serialization = ["dep:serde", "dep:serde-big-array"]

[dev-dependencies]
rand = "0.8.5"
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-mldsa/src/mldsa44.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ simple_struct!(PublicKey, ffi::PQCLEAN_MLDSA44_CLEAN_CRYPTO_PUBLICKEYBYTES);
simple_struct!(SecretKey, ffi::PQCLEAN_MLDSA44_CLEAN_CRYPTO_SECRETKEYBYTES);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_MLDSA44_CLEAN_CRYPTO_BYTES],
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-mldsa/src/mldsa65.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ simple_struct!(PublicKey, ffi::PQCLEAN_MLDSA65_CLEAN_CRYPTO_PUBLICKEYBYTES);
simple_struct!(SecretKey, ffi::PQCLEAN_MLDSA65_CLEAN_CRYPTO_SECRETKEYBYTES);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_MLDSA65_CLEAN_CRYPTO_BYTES],
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-mldsa/src/mldsa87.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ simple_struct!(PublicKey, ffi::PQCLEAN_MLDSA87_CLEAN_CRYPTO_PUBLICKEYBYTES);
simple_struct!(SecretKey, ffi::PQCLEAN_MLDSA87_CLEAN_CRYPTO_SECRETKEYBYTES);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_MLDSA87_CLEAN_CRYPTO_BYTES],
Expand Down
4 changes: 2 additions & 2 deletions pqcrypto-mlkem/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ categories = ["cryptography", "no-std"]
pqcrypto-internals = { path = "../pqcrypto-internals", version = "0.2.6" }
pqcrypto-traits = { path = "../pqcrypto-traits", version = "0.3.5", default-features = false }
libc = "0.2.0"
serde = { version = "1.0", features = ["derive"], optional = true }
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"], optional = true }
serde-big-array = { version = "0.5.1", optional = true }

[features]
default = ["avx2", "neon", "std"]
avx2 = ["std"]
neon = ["std"]
std = ["pqcrypto-traits/std"]
serialization = ["serde", "serde-big-array"]
serialization = ["dep:serde", "dep:serde-big-array"]

[dev-dependencies]

Expand Down
4 changes: 2 additions & 2 deletions pqcrypto-sphincsplus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ categories = ["cryptography", "no-std"]
pqcrypto-internals = { path = "../pqcrypto-internals", version = "0.2.6" }
pqcrypto-traits = { path = "../pqcrypto-traits", version = "0.3.5", default-features = false }
libc = "0.2.0"
serde = { version = "1.0", features = ["derive"], optional = true }
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"], optional = true }
serde-big-array = { version = "0.5.1", optional = true }

[features]
default = ["avx2", "std"]
avx2 = ["std"]
std = ["pqcrypto-traits/std"]
serialization = ["serde", "serde-big-array"]
serialization = ["dep:serde", "dep:serde-big-array"]

[dev-dependencies]
rand = "0.8.5"
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-sphincsplus/src/sphincssha2128fsimple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ simple_struct!(
);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_SPHINCSSHA2128FSIMPLE_CLEAN_CRYPTO_BYTES],
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-sphincsplus/src/sphincssha2128ssimple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ simple_struct!(
);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_SPHINCSSHA2128SSIMPLE_CLEAN_CRYPTO_BYTES],
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-sphincsplus/src/sphincssha2192fsimple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ simple_struct!(
);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_SPHINCSSHA2192FSIMPLE_CLEAN_CRYPTO_BYTES],
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-sphincsplus/src/sphincssha2192ssimple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ simple_struct!(
);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_SPHINCSSHA2192SSIMPLE_CLEAN_CRYPTO_BYTES],
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-sphincsplus/src/sphincssha2256fsimple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ simple_struct!(
);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_SPHINCSSHA2256FSIMPLE_CLEAN_CRYPTO_BYTES],
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-sphincsplus/src/sphincssha2256ssimple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ simple_struct!(
);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_SPHINCSSHA2256SSIMPLE_CLEAN_CRYPTO_BYTES],
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-sphincsplus/src/sphincsshake128fsimple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ simple_struct!(
);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_SPHINCSSHAKE128FSIMPLE_CLEAN_CRYPTO_BYTES],
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-sphincsplus/src/sphincsshake128ssimple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ simple_struct!(
);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_SPHINCSSHAKE128SSIMPLE_CLEAN_CRYPTO_BYTES],
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-sphincsplus/src/sphincsshake192fsimple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ simple_struct!(
);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_SPHINCSSHAKE192FSIMPLE_CLEAN_CRYPTO_BYTES],
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-sphincsplus/src/sphincsshake192ssimple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ simple_struct!(
);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_SPHINCSSHAKE192SSIMPLE_CLEAN_CRYPTO_BYTES],
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-sphincsplus/src/sphincsshake256fsimple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ simple_struct!(
);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_SPHINCSSHAKE256FSIMPLE_CLEAN_CRYPTO_BYTES],
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-sphincsplus/src/sphincsshake256ssimple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ simple_struct!(
);

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_SPHINCSSHAKE256SSIMPLE_CLEAN_CRYPTO_BYTES],
Expand Down
4 changes: 2 additions & 2 deletions pqcrypto-template/scheme/Cargo.toml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ categories = ["cryptography", "no-std"]
pqcrypto-internals = { path = "../pqcrypto-internals", version = "0.2.6" }
pqcrypto-traits = { path = "../pqcrypto-traits", version = "{{ traits_version }}", default-features = false }
libc = "0.2.0"
serde = { version = "1.0", features = ["derive"], optional = true }
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"], optional = true }
serde-big-array = { version = "0.5.1", optional = true }
{% if supports_context %}
paste = "1.0"
Expand All @@ -33,7 +33,7 @@ aes = ["std"]
neon = ["std"]
{% endif %}
std = ["pqcrypto-traits/std"]
serialization = ["serde", "serde-big-array"]
serialization = ["dep:serde", "dep:serde-big-array"]
{% if insecure %}
cryptographically-insecure = []
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion pqcrypto-template/scheme/src/scheme.rs.j2
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ simple_struct!(SharedSecret, ffi::PQCLEAN_{{ NS_NAME }}_CRYPTO_BYTES);
{% else %}

#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct DetachedSignature(
#[cfg_attr(feature = "serialization", serde(with = "BigArray"))]
[u8; ffi::PQCLEAN_{{ NS_NAME }}_CRYPTO_BYTES],
Expand Down

0 comments on commit 9412679

Please sign in to comment.