Skip to content

Commit ce3590d

Browse files
authored
Merge pull request #83 from joechrisellis/add-list-keys
Add ListKeys operation
2 parents 2cb516f + c0d5229 commit ce3590d

File tree

7 files changed

+409
-1
lines changed

7 files changed

+409
-1
lines changed

src/operations/list_keys.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2020 Contributors to the Parsec project.
2+
// SPDX-License-Identifier: Apache-2.0
3+
//! # ListKeys operation
4+
//!
5+
//! Lists all keys belonging to the application.
6+
use super::psa_key_attributes::Attributes;
7+
use crate::requests::ProviderID;
8+
9+
/// Structure holding the basic information for a key in the application for client discovery.
10+
#[derive(Debug, Clone, PartialEq)]
11+
pub struct KeyInfo {
12+
/// The ID of the associated provider.
13+
pub provider_id: ProviderID,
14+
/// The name of the key.
15+
pub name: String,
16+
/// The key attributes.
17+
pub attributes: Attributes,
18+
}
19+
20+
/// Native object for key listing operation.
21+
#[derive(Copy, Clone, Debug)]
22+
pub struct Operation;
23+
24+
/// Native object for key listing result.
25+
#[derive(Debug)]
26+
pub struct Result {
27+
/// A list of `KeyInfo` structures.
28+
pub keys: Vec<KeyInfo>,
29+
}

src/operations/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub mod psa_aead_decrypt;
2626
pub mod list_opcodes;
2727
pub mod list_providers;
2828
pub mod list_authenticators;
29+
pub mod list_keys;
2930
pub mod psa_generate_random;
3031
pub mod psa_raw_key_agreement;
3132

@@ -44,6 +45,8 @@ pub enum NativeOperation {
4445
ListOpcodes(list_opcodes::Operation),
4546
/// ListAuthenticators operation
4647
ListAuthenticators(list_authenticators::Operation),
48+
/// ListKeys operation
49+
ListKeys(list_keys::Operation),
4750
/// Ping operation
4851
Ping(ping::Operation),
4952
/// PsaGenerateKey operation
@@ -95,6 +98,7 @@ impl NativeOperation {
9598
NativeOperation::ListOpcodes(_) => Opcode::ListOpcodes,
9699
NativeOperation::ListProviders(_) => Opcode::ListProviders,
97100
NativeOperation::ListAuthenticators(_) => Opcode::ListAuthenticators,
101+
NativeOperation::ListKeys(_) => Opcode::ListKeys,
98102
NativeOperation::PsaAsymmetricEncrypt(_) => Opcode::PsaAsymmetricEncrypt,
99103
NativeOperation::PsaAsymmetricDecrypt(_) => Opcode::PsaAsymmetricDecrypt,
100104
NativeOperation::PsaAeadEncrypt(_) => Opcode::PsaAeadEncrypt,
@@ -115,6 +119,8 @@ pub enum NativeResult {
115119
ListOpcodes(list_opcodes::Result),
116120
/// ListAuthenticators result
117121
ListAuthenticators(list_authenticators::Result),
122+
/// ListKeys result
123+
ListKeys(list_keys::Result),
118124
/// Ping result
119125
Ping(ping::Result),
120126
/// PsaGenerateKey result
@@ -166,6 +172,7 @@ impl NativeResult {
166172
NativeResult::ListOpcodes(_) => Opcode::ListOpcodes,
167173
NativeResult::ListProviders(_) => Opcode::ListProviders,
168174
NativeResult::ListAuthenticators(_) => Opcode::ListAuthenticators,
175+
NativeResult::ListKeys(_) => Opcode::ListKeys,
169176
NativeResult::PsaAsymmetricEncrypt(_) => Opcode::PsaAsymmetricEncrypt,
170177
NativeResult::PsaAsymmetricDecrypt(_) => Opcode::PsaAsymmetricDecrypt,
171178
NativeResult::PsaAeadEncrypt(_) => Opcode::PsaAeadEncrypt,
@@ -225,6 +232,12 @@ impl From<list_authenticators::Operation> for NativeOperation {
225232
}
226233
}
227234

235+
impl From<list_keys::Operation> for NativeOperation {
236+
fn from(op: list_keys::Operation) -> Self {
237+
NativeOperation::ListKeys(op)
238+
}
239+
}
240+
228241
impl From<ping::Operation> for NativeOperation {
229242
fn from(op: ping::Operation) -> Self {
230243
NativeOperation::Ping(op)
@@ -338,6 +351,12 @@ impl From<list_authenticators::Result> for NativeResult {
338351
}
339352
}
340353

354+
impl From<list_keys::Result> for NativeResult {
355+
fn from(op: list_keys::Result) -> Self {
356+
NativeResult::ListKeys(op)
357+
}
358+
}
359+
341360
impl From<ping::Result> for NativeResult {
342361
fn from(op: ping::Result) -> Self {
343362
NativeResult::Ping(op)

0 commit comments

Comments
 (0)