Skip to content

Commit aaa9178

Browse files
authored
Merge branch 'main' into propq
2 parents 96dddf7 + 85cb68d commit aaa9178

File tree

21 files changed

+164
-22
lines changed

21 files changed

+164
-22
lines changed

.github/workflows/openjdk-integration.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ jobs:
2626
dnf --assumeyes --disable-repo=fedora-cisco-openh264 \
2727
install git cargo clang-devel openssl-devel zlib-devel sed \
2828
sqlite-devel openssl opensc unzip wget \
29-
java-${{ env.openjdk_feature }}-openjdk-devel
29+
java-${{ env.openjdk_feature }}-openjdk-devel \
30+
'perl(FindBin)' 'perl(lib)' 'perl(File::Compare)' \
31+
'perl(File::Copy)' 'perl(bigint)' 'perl(Time::HiRes)' \
32+
'perl(IPC::Cmd)' 'perl(Pod::Html)' 'perl(Digest::SHA)' \
33+
'perl(Module::Load::Conditional)' 'perl(File::Temp)' \
34+
'perl(Test::Harness)' 'perl(Test::More)' 'perl(Math::BigInt)'
3035
3136
# Kryoptic build steps; try to keep in sync with relevant build.yml steps.
3237
- name: Checkout Repository

ossl/src/asymcipher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct RsaOaepParams {
2828
pub fn rsa_enc_params(
2929
alg: EncAlg,
3030
oaep_params: Option<&RsaOaepParams>,
31-
) -> Result<OsslParam, Error> {
31+
) -> Result<OsslParam<'_>, Error> {
3232
let mut params_builder = crate::OsslParamBuilder::new();
3333

3434
match alg {

ossl/src/fips.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ struct MemBio<'a> {
340340
}
341341

342342
impl MemBio<'_> {
343-
fn new(v: &mut [u8]) -> MemBio {
343+
fn new(v: &mut [u8]) -> MemBio<'_> {
344344
MemBio { mem: v, cursor: 0 }
345345
}
346346

ossl/src/pkey.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ impl EvpPkey {
850850
///
851851
/// The `selection` argument specifies which components to export
852852
/// (e.g., public, private, parameters).
853-
fn export_params(&self, selection: u32) -> Result<OsslParam, Error> {
853+
fn export_params(&self, selection: u32) -> Result<OsslParam<'_>, Error> {
854854
let mut params_builder = OsslParamBuilder::new();
855855
params_builder.zeroize = true;
856856
let ret = unsafe {

ossl/src/signature.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ pub struct RsaPssParams {
300300
pub fn rsa_sig_params(
301301
alg: SigAlg,
302302
pss_params: &Option<RsaPssParams>,
303-
) -> Result<Option<OsslParam>, Error> {
303+
) -> Result<Option<OsslParam<'_>>, Error> {
304304
match alg {
305305
SigAlg::RsaNoPad => {
306306
let mut params_builder = OsslParamBuilder::new();

src/attribute.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ impl Attribute {
462462
}
463463

464464
/// Constructs an attribute passing in the value as a slice
465+
#[cfg(feature = "nssdb")]
465466
pub fn from_attr_slice(
466467
id: CK_ULONG,
467468
at: AttrType,

src/fips/indicators.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ struct FipsMechanism {
283283
/// Struct that holds FIPS properties for keys and mechanisms
284284
struct FipsChecks {
285285
keys: [FipsKeyType; 17],
286-
mechs: [FipsMechanism; 91],
286+
mechs: [FipsMechanism; 93],
287287
}
288288

289289
/// A constant instantiation of FIPS properties with a list
@@ -552,6 +552,19 @@ const FIPS_CHECKS: FipsChecks = FipsChecks {
552552
restrictions: [restrict!(CKK_EC), restrict!()],
553553
genflags: 0,
554554
},
555+
/* EDDSA */
556+
FipsMechanism {
557+
mechanism: CKM_EC_EDWARDS_KEY_PAIR_GEN,
558+
operations: CKF_GENERATE_KEY_PAIR,
559+
restrictions: [restrict!(CKK_EC_EDWARDS), restrict!()],
560+
genflags: CKF_SIGN | CKF_VERIFY,
561+
},
562+
FipsMechanism {
563+
mechanism: CKM_EDDSA,
564+
operations: CKF_SIGN | CKF_VERIFY,
565+
restrictions: [restrict!(CKK_EC_EDWARDS), restrict!()],
566+
genflags: 0,
567+
},
555568
/* AES */
556569
FipsMechanism {
557570
mechanism: CKM_AES_KEY_GEN,
@@ -1315,6 +1328,17 @@ pub fn is_key_approved(key: &Object, op: CK_FLAGS) -> bool {
13151328
check_key(key, op, None, None)
13161329
}
13171330

1331+
/// Adds validation flag to the object, if it is not yet present
1332+
/// and if the object passes validation rules.
1333+
pub fn add_missing_validation_flag(key: &mut Object) {
1334+
if let Ok(_) = key.get_attr_as_ulong(CKA_OBJECT_VALIDATION_FLAGS) {
1335+
return;
1336+
}
1337+
if is_key_approved(key, CK_UNAVAILABLE_INFORMATION) {
1338+
add_fips_flag(key);
1339+
}
1340+
}
1341+
13181342
/// Helper to check if an operation is approved
13191343
///
13201344
/// Applies key checks as well as mechanism checks according to the

src/kasn1/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl PrivateKeyInfo<'_> {
207207
}
208208

209209
/// Returns the key type (as an OID)
210-
pub fn get_algorithm(&self) -> &pkcs::AlgorithmIdentifier {
210+
pub fn get_algorithm(&self) -> &pkcs::AlgorithmIdentifier<'_> {
211211
&self.algorithm
212212
}
213213

src/object.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,9 @@ pub trait ObjectFactory: Debug + Send + Sync {
850850
match attrs.iter().find(|a| a.get_type() == ck_attr.type_) {
851851
None => return Err(CKR_ATTRIBUTE_TYPE_INVALID)?,
852852
Some(attr) => {
853+
if attr.is(OAFlags::NeverSettable) {
854+
return Err(CKR_ACTION_PROHIBITED)?;
855+
}
853856
if attr.is(OAFlags::Unchangeable) {
854857
if attr.attribute.get_attrtype() == AttrType::BoolType {
855858
let val = ck_attr.to_bool()?;

src/storage/format.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use std::fmt::Debug;
1111

1212
use crate::attribute::{Attribute, CkAttrs};
1313
use crate::error::Result;
14+
#[cfg(feature = "fips")]
15+
use crate::fips::indicators::add_missing_validation_flag;
1416
use crate::object::Object;
1517
use crate::pkcs11::*;
1618
use crate::storage::aci::{StorageACI, StorageAuthInfo};
@@ -297,6 +299,13 @@ impl Storage for StdStorageFormat {
297299
* some attributes or not */
298300
attrs.add_missing_ulong(CKA_SENSITIVE, &dnm);
299301
attrs.add_missing_ulong(CKA_EXTRACTABLE, &dnm);
302+
#[cfg(feature = "fips")]
303+
{
304+
/* We need these to be able to derive object validation flag */
305+
attrs.add_missing_ulong(CKA_EC_PARAMS, &dnm);
306+
attrs.add_missing_ulong(CKA_VALUE_LEN, &dnm);
307+
attrs.add_missing_ulong(CKA_MODULUS, &dnm);
308+
}
300309
}
301310

302311
let mut obj = self.store.fetch_by_uid(&uid, attrs.as_slice())?;
@@ -315,6 +324,9 @@ impl Storage for StdStorageFormat {
315324
}
316325
}
317326

327+
#[cfg(feature = "fips")]
328+
add_missing_validation_flag(&mut obj);
329+
318330
obj.set_handle(handle);
319331
Ok(obj)
320332
}

0 commit comments

Comments
 (0)