Skip to content

Commit bbbfef5

Browse files
simo5Gemini
andcommitted
Use standard CKR_TOKEN_NOT_INITIALIZED error
Replace the custom vendor error `KRR_TOKEN_NOT_INITIALIZED` with the standard PKCS#11 error `CKR_TOKEN_NOT_INITIALIZED`. This resolves a FIXME and improves compliance with the PKCS#11 standard by using a standard error code where appropriate. Co-authored-by: Gemini <gemini@google.com> Signed-off-by: Simo Sorce <simo@redhat.com>
1 parent a2c1ce2 commit bbbfef5

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/pkcs11/vendor.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ pub const KRA_LOGIN_ATTEMPTS: CK_ATTRIBUTE_TYPE = KRY_VENDOR_OFFSET + 2;
1717
/* + 10 taken by pkcs11/validation_draft.rs */
1818

1919
/* Errors */
20-
pub const KRR_TOKEN_NOT_INITIALIZED: CK_ULONG = KRY_VENDOR_OFFSET + 1;
20+
/* R.I.P. KRR_TOKEN_NOT_INITIALIZED (1),
21+
* you served us well (replaced by CKR_TOKEN_NOT_INITIALIZED)
22+
*/
2123
pub const KRR_SLOT_CONFIG: CK_ULONG = KRY_VENDOR_OFFSET + 2;
2224
pub const KRR_CONFIG_ERROR: CK_ULONG = KRY_VENDOR_OFFSET + 3;
2325

src/slot.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use crate::config;
1111
use crate::defaults;
1212
use crate::error::Result;
1313
use crate::misc::copy_sized_string;
14-
use crate::pkcs11::vendor::KRR_TOKEN_NOT_INITIALIZED;
1514
use crate::pkcs11::*;
1615
use crate::session::Session;
1716
use crate::token::Token;
@@ -111,9 +110,7 @@ impl Slot {
111110
if token.is_initialized() {
112111
Ok(token)
113112
} else {
114-
/* FIXME: once we have CKR_TOKEN_NOT_INITIALIZED as an
115-
* available error, we should rreturn that instead */
116-
Err(KRR_TOKEN_NOT_INITIALIZED)?
113+
Err(CKR_TOKEN_NOT_INITIALIZED)?
117114
}
118115
}
119116
Err(_) => Err(CKR_GENERAL_ERROR)?,
@@ -134,9 +131,7 @@ impl Slot {
134131
} else if token.is_initialized() {
135132
Ok(token)
136133
} else {
137-
/* FIXME: once we have CKR_TOKEN_NOT_INITIALIZED as an
138-
* available error, we should rreturn that instead */
139-
Err(KRR_TOKEN_NOT_INITIALIZED)?
134+
Err(CKR_TOKEN_NOT_INITIALIZED)?
140135
}
141136
}
142137
Err(_) => Err(CKR_GENERAL_ERROR)?,

0 commit comments

Comments
 (0)