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

crypto_authenc_update_aad on decrypt path in hash tree #6532

Closed
Amit-Radur opened this issue Dec 7, 2023 · 5 comments
Closed

crypto_authenc_update_aad on decrypt path in hash tree #6532

Amit-Radur opened this issue Dec 7, 2023 · 5 comments

Comments

@Amit-Radur
Copy link

Amit-Radur commented Dec 7, 2023

I have few queries regarding crypto function used under hash tree.

  1. Do we really need to call crypto_authenc_update_aad when TEE_OperationMode is decrypt, shouldn't the Additional
    authenticated data is updated only when TEE_OperationMode is encrypt ?

    https://github.com/OP-TEE/optee_os/blob/master/core/tee/fs_htree.c#L476C9-L476C34

  2. Is this a BUG, using TEE_FS_HTREE_FEK_SIZE instead of TEE_FS_HTREE_HASH_SIZE ?

``

        if (!ni) {
               res = crypto_authenc_update_aad(ctx, mode, ht->root.node.hash,
 -                                               TEE_FS_HTREE_FEK_SIZE);
 +                                               TEE_FS_HTREE_HASH_SIZE);
  1. How do one fully reset secure storage, do we need to create the /data/tee directory every time we wanted to reset
    the secure storage ?
@jenswi-linaro
Copy link
Contributor

  1. Yes, it's needed to calculate the tag correctly.
  2. Yes, fixing it will unfortunately break already existing secure storage objects. This means that we're currently using truncated SHA-256 hashes. I would very much like to fix this, but we should do it in a compatible way.
  3. That depends on what you use for rollback protection. If you have none, it's enough to remove the content of /data/tee.

@jenswi-linaro
Copy link
Contributor

@Amit-Radur
Copy link
Author

@jenswi-linaro , run the "optee_example_secure_storage" after deleting the content of /data/tee (and encrypt/decrypt is offloaded to my platform specific authenc/cipher block) but I see plain data here is printed as 0.

https://github.com/OP-TEE/optee_os/blob/master/core/tee/fs_htree.c#L528

May I know the reason why imeta data (&ht->imeta) is not populated here properly, and all I see is 0's ?

@jenswi-linaro
Copy link
Contributor

I'm sorry, I can't help debugging your code.

@Amit-Radur
Copy link
Author

Sure, No issues. I am closing it as your answers helped me with few things.

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

No branches or pull requests

2 participants