summaryrefslogtreecommitdiffstats
path: root/vendor/sec1/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/sec1/tests
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/sec1/tests')
-rw-r--r--vendor/sec1/tests/private_key.rs11
-rw-r--r--vendor/sec1/tests/traits.rs2
2 files changed, 12 insertions, 1 deletions
diff --git a/vendor/sec1/tests/private_key.rs b/vendor/sec1/tests/private_key.rs
index 5b985da84..224a947e7 100644
--- a/vendor/sec1/tests/private_key.rs
+++ b/vendor/sec1/tests/private_key.rs
@@ -6,6 +6,9 @@ use der::asn1::ObjectIdentifier;
use hex_literal::hex;
use sec1::{EcParameters, EcPrivateKey};
+#[cfg(feature = "alloc")]
+use der::Encode;
+
/// NIST P-256 SEC1 private key encoded as ASN.1 DER.
///
/// Note: this key is extracted from the corresponding `p256-priv.der`
@@ -30,3 +33,11 @@ fn decode_p256_der() {
);
assert_eq!(key.public_key, Some(hex!("041CACFFB55F2F2CEFD89D89EB374B2681152452802DEEA09916068137D839CF7FC481A44492304D7EF66AC117BEFE83A8D08F155F2B52F9F618DD447029048E0F").as_ref()));
}
+
+#[cfg(feature = "alloc")]
+#[test]
+fn encode_p256_der() {
+ let key = EcPrivateKey::try_from(P256_DER_EXAMPLE).unwrap();
+ let key_encoded = key.to_der().unwrap();
+ assert_eq!(P256_DER_EXAMPLE, key_encoded);
+}
diff --git a/vendor/sec1/tests/traits.rs b/vendor/sec1/tests/traits.rs
index 4bcd679b9..ab6e09a20 100644
--- a/vendor/sec1/tests/traits.rs
+++ b/vendor/sec1/tests/traits.rs
@@ -1,6 +1,6 @@
//! Tests for SEC1 encoding/decoding traits.
-#![cfg(any(feature = "pem", feature = "std"))]
+#![cfg(any(feature = "pem", all(feature = "der", feature = "std")))]
use der::SecretDocument;
use sec1::{DecodeEcPrivateKey, EncodeEcPrivateKey, Result};