Skip to content

Conversation

MaxKingPor
Copy link

add sm2 pke no std support
ref #1099

sm2/src/dsa.rs Outdated
#[cfg(feature = "pkcs8")]
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you changing this? Everything but SignatureBitStringEncoding is available in no-alloc environments

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you resolve this comment without answering or changing anything?

@MaxKingPor
Copy link
Author

MaxKingPor commented Jul 23, 2025

@tarcieri I'm sorry, I've replied, but it seems that you can't see it over there
IMG_20250724_001532


These imports are only used in impl near line 215

#[cfg(all(feature = "alloc", feature = "pkcs8"))]
impl SignatureBitStringEncoding for Signature {
fn to_bitstring(&self) -> der::Result<der::asn1::BitString> {
der::asn1::BitString::new(0, self.to_vec())
}
}
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
impl AssociatedAlgorithmIdentifier for Signature {
type Params = AnyRef<'static>;
const ALGORITHM_IDENTIFIER: AlgorithmIdentifierRef<'static> = AlgorithmIdentifierRef {
// Reference: https://datatracker.ietf.org/doc/html/draft-sca-cfrg-sm3#section-8.1.3
// ```
// "1.2.156.10197.1.501" for "Digital Signature: SM2 and SM3"
// o "id-dsa-sm2sm3" "{id-int dsa-sm2sm3(501)}"
// ```
//
// NOTE: Here [`Signature`] represent an SM2 signed object with an SM3 hash (implementation detail
// of [`sm2::dsa::SigningKey`] and [`sm2::dsa::VerifyingKey`], that might need to change
// once/if the hash function gets modular.
oid: ObjectIdentifier::new_unwrap("1.2.156.10197.1.501"),
parameters: None,
};
}

@tarcieri
Copy link
Member

Oh, your comment is marked pending. I’m on a phone but I’m confused why there wouldn’t be unused import warnings in thar case.

@MaxKingPor
Copy link
Author

The current main branch uses std by default

@tarcieri
Copy link
Member

By "default" in the sense of a default-enabled std (and alloc) feature, not unconditionally:

https://github.com/RustCrypto/elliptic-curves/blob/8f6a343/sm2/Cargo.toml#L38-L40

@MaxKingPor
Copy link
Author

Sorry I didn't know this, but now I've changed it back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants