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

CLI fails to create COSE using Azure KeyVault RSA key #181

Open
ivarprudnikov opened this issue Feb 27, 2024 · 0 comments
Open

CLI fails to create COSE using Azure KeyVault RSA key #181

ivarprudnikov opened this issue Feb 27, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ivarprudnikov
Copy link
Member

ivarprudnikov commented Feb 27, 2024

Describe the bug

Cannot use sign operation with an RSA key. The underlying cose signing operation does not support RSA it seems https://github.com/microsoft/CCF/blob/a58d2c880b3691211ed7fa68b684e1ef5bfabf4c/python/ccf/cose.py#L82

To Reproduce

  1. Generate a self signed RSA 4096 cert in AKV

  2. Get the public key

    • az keyvault certificate download --vault-name $VAULTNAME -n $CERTNAME -f cabundle.pem -e PEM
  3. Create AKV details json file for the CLI to use akv-config.json:

    {
      "keyVaultName":"$VAULTNAME","certificateName":"$CERTNAME","certificateVersion":"$version"
    }
  4. Create a sample file to sign claim-foobar.txt

  5. Invoke the CLI to create a signature:

    scitt sign --claims claim-foobar.txt --content-type "text/plain" --akv-configuration akv-config.json --x5c cabundle.pem --out claim.cose
  6. The failure:

    Traceback (most recent call last):
      File "/home/ubuntu/.local/bin/scitt", line 11, in <module>
        load_entry_point('pyscitt', 'console_scripts', 'scitt')()
      File "/home/ubuntu/scitt-ccf-ledger/pyscitt/pyscitt/cli/main.py", line 42, in main
        args.func(args)
      File "/home/ubuntu/scitt-ccf-ledger/pyscitt/pyscitt/cli/sign_claims.py", line 211, in <lambda>
        func=lambda args: sign_claims(
      File "/home/ubuntu/scitt-ccf-ledger/pyscitt/pyscitt/cli/sign_claims.py", line 141, in sign_claims
        signed_claims = kv_client.cose_sign(
      File "/home/ubuntu/scitt-ccf-ledger/pyscitt/pyscitt/key_vault_sign_client.py", line 81, in cose_sign
        tbs = create_cose_sign1_prepare(
      File "/home/ubuntu/.local/lib/python3.8/site-packages/ccf/cose.py", line 143, in create_cose_sign1_prepare
        alg = default_algorithm_for_key(cert.public_key())
      File "/home/ubuntu/.local/lib/python3.8/site-packages/ccf/cose.py", line 96, in default_algorithm_for_key
        raise NotImplementedError("unsupported key type")
    NotImplementedError: unsupported key type
    

Expected behavior
The command should not complain and sign the payload

@ivarprudnikov ivarprudnikov added the bug Something isn't working label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant