Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

API Gap: KeyWrapper, KeyUwrapper

Aperta
#150 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@roy-basmacier ci sta già lavorando.

Dal 22/9/2026.

  • #160 di @roy-basmacier — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

These are also on the OpenSSL list with the driving specifications being SP 800-38F "Recommendation for Block Cipher Modes of Operation: Methods for Key Wrapping" and RFC 5649.

Primarily the algorithms described are for AES and TDES, however Aria and Camellia (and I think SM4, not 100% sure....) support the same algorithms.

The algorithms require the full material being wrapped to be passed in.

Typing all this into Opus resulted in a suggestion looking like this:

pub trait KeyWrapper<const KEK_LEN: usize>: Algorithm {
    /// Half the underlying block cipher's block size, in bytes -- "semiblock", Sec. 4.1.
    /// 8 for KW and KWP (128-bit block); 4 for TKW (TDEA, 64-bit block).
    const SEMIBLOCK_LEN: usize;

    /// Wraps `key` under `kek`. `CT_LEN` is determined by `KEY_LEN` and checked at compile time.
    ///
    /// # Errors
    /// Rejects a KEK whose [`KeyType`] is not [`KeyType::SymmetricCipherKey`], and one whose
    /// security strength is below that of the key being wrapped (Appendix A.2), both as
    /// [`KeyWrapError::KeyMaterialError`].
    fn wrap_key<const KEY_LEN: usize, const CT_LEN: usize>(
        kek: &KeyMaterial<KEK_LEN>,
        key: &KeyMaterial<KEY_LEN>,
    ) -> Result<[u8; CT_LEN], KeyWrapError>;

    /// As [`wrap_key`](Self::wrap_key), writing into a caller-provided buffer. Returns the number
    /// of bytes written, which is always `CT_LEN`.
    fn wrap_key_out<const KEY_LEN: usize, const CT_LEN: usize>(
        kek: &KeyMaterial<KEK_LEN>,
        key: &KeyMaterial<KEY_LEN>,
        ciphertext: &mut [u8; CT_LEN],
    ) -> Result<usize, KeyWrapError> {
        *ciphertext = Self::wrap_key(kek, key)?;
        Ok(CT_LEN)
    }
}

With an equivalent trait for KeyUnwrapper. I note KeyWrapErrror is also new.

Also of note is that these algorithms (especially the KWP (padded) format), get used for things other than symmetric and private keys. So while the suggestion above shows KeyMaterial going in (mostly correct) input as [u8] might be better.

Lingua principale
Rust
Stelle
25
Fork
18
Merge medio
7g 13m
PR unite (30g)
3

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bcgit/bc-rust

Tutte le issue di bcgit/bc-rust

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.