Skip to content

#267 Modify get_attribute_info_map to take slice instead of vec #273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cryptoki/src/session/object_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,9 @@ impl Session {
pub fn get_attribute_info_map(
&self,
object: ObjectHandle,
attributes: Vec<AttributeType>,
attributes: &[AttributeType],
) -> Result<HashMap<AttributeType, AttributeInfo>> {
let attrib_info = self.get_attribute_info(object, attributes.as_slice())?;
let attrib_info = self.get_attribute_info(object, attributes)?;

Ok(attributes
.iter()
Expand Down
7 changes: 4 additions & 3 deletions cryptoki/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1197,8 +1197,9 @@ fn get_attribute_info_test() -> TestResult {
session.generate_key_pair(&mechanism, &pub_key_template, &priv_key_template)?;

let pub_attribs = vec![AttributeType::PublicExponent, AttributeType::Modulus];
let mut priv_attribs = pub_attribs.clone();
priv_attribs.push(AttributeType::PrivateExponent);
let mut priv_attribs = [
AttributeType::PublicExponent, AttributeType::Modulus, AttributeType::PrivateExponent
];

let attrib_info = session.get_attribute_info(public, &pub_attribs)?;
let hash = pub_attribs
Expand Down Expand Up @@ -1239,7 +1240,7 @@ fn get_attribute_info_test() -> TestResult {
_ => panic!("Private Exponent of RSA private key should be sensitive"),
}

let hash = session.get_attribute_info_map(private, priv_attribs)?;
let hash = session.get_attribute_info_map(private, &priv_attribs)?;
if let AttributeInfo::Available(size) = hash[&AttributeType::Modulus] {
assert_eq!(size, 2048 / 8);
} else {
Expand Down
Loading