Skip to content
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

oaep: support non-string labels #467

Merged
merged 1 commit into from
Feb 13, 2025

Conversation

baloo
Copy link
Member

@baloo baloo commented Jan 30, 2025

This rework oaep to support non-string labels.
One use-case is encryption of secrets in TPM.

https://trustedcomputinggroup.org/wp-content/uploads/TPM-2.0-1.83-Part-1-Architecture.pdf#page=297
Section B.4 RSAES_OAEP

For RSA keys protecting a secret value (such as, an encryption key or a session secret), the L parameter
is a byte stream, the last byte of which must be zero, indicating the intended use of the encrypted value. 

That would look like:

    let encrypted_seed = {
        let padding = Oaep::new_with_label::<EkHash, _>(b"IDENTITY\0".to_vec());
        let enc_data = ek_public
            .encrypt(&mut rng, padding, &random_seed[..])
            .expect("failed to encrypt");
        enc_data
    };

@baloo
Copy link
Member Author

baloo commented Jan 30, 2025

I'm pulling this PR in parallaxsecond/rust-tss-esapi#563

@tarcieri
Copy link
Member

@baloo can you rebase?

@baloo baloo force-pushed the baloo/oaep/non-string-label branch from b265411 to dd0b96f Compare February 13, 2025 17:12
@tarcieri tarcieri merged commit 8e8bd6a into RustCrypto:master Feb 13, 2025
11 checks passed
@baloo baloo deleted the baloo/oaep/non-string-label branch February 13, 2025 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants