OASIS PKCS 11 TC

 View Only
  • 1.  MessageEncrypt related editorial comments

    Posted 09-11-2024 17:27
    When trying to implement MessageEncryption interfaces there are a
    couple of things that popped up to my attention.

    1) C_MessageEncryptInit (5.9.1 in v3.1) does not specify what the
    pParameter/ulParameterLen of the pMechanism structure should be, my
    understanding is that they should always be NULL because the actual
    parameters are always defined on
    C_EncryptMessage/C_EncryptMessageBegin/C_MessageEncryptNext but that is
    not made explicit in the text and perhaps is not true otherwise I would
    have expected the function to take a CKM_MECHANISM_TYPE parameter
    instead of CKM_MECHANISM_PTR, some text either way would be nice.

    If pParameter can be not null then the specific mechanisms implementing
    CKF_MESSAGE_ENCRYPT etc should specify it which brings me to AES GCM
    which is the only mechanism I looked into so far.

    2) In "6.13 Additional AES Mechanisms"
    I think the table should show EncryptMessage/DecryptMessage as
    supported Functions in an additional column

    3) In "6.13.2 AES-GCM Authenticated Encryption / Decryption"
    Under the "MessageEncrypt:" section the last bulle point says:
    "Call C_MessageEncryptFinal() to close the message decryption."

    Two problems:
    3.1) decryption should really be encryption

    3.2) I think this bulle point should rather say that
    C_EncryptMessageNext() should be called with flags=CKF_END_OF_MESSAGE
    to complete the message, because C_MessageEncryptFinal() is used to
    terminate the whole message encryption operation not a single message.

    Alternatively eliminate the bullet point entirely and rely on the
    explanation in 5.9.3 C_EncryptMessageBegin which already explains the
    use of flags=CKF_END_OF_MESSAGE

    Eliminating the last bullet point would be ok because the whole 6.13.2
    section does not mention the use C_MessageEncryptInit() either.

    4) Same as (3.2) for the "MessageDecrypt:" section

    5) [uncertain] The two sections should probably be renamed:
    MessageEncrypt -> EncryptMessage
    MessageDecrypt -> DecryptMessage
    to aligne with the name of the function used for the individual message
    encryptions.

    6) in the ending of "6.13.2 AES-GCM Authenticated Encryption /
    Decryption" one line says:

    - CKG_GENERATE_COUNTER_XOR means that the non-fixed portion of the IV
    is xored with a counter. The value of the non-fixed portion passed must
    not vary from call to call.

    Does this mean that the fixed portion can vary? Or should this say that
    the input IV should not vary from call to call ? Perhaps it should be
    made clear if the generated IV is returned in pIV for these calls
    because it would then tell the application developer whether they need
    to actively save the IV in a separate buffer for each call (or not).


    HTH,
    Simo.

    --
    Simo Sorce
    Distinguished Engineer
    RHEL Crypto Team
    Red Hat, Inc


  • 2.  RE: MessageEncrypt related editorial comments

    Posted 09-12-2024 12:42

    1) C_MessageEncryptInit (5.9.1 in v3.1) does not specify what the
    pParameter/ulParameterLen of the pMechanism structure should be, my
    understanding is that they should always be NULL because the actual
    parameters are always defined on
    C_EncryptMessage/C_EncryptMessageBegin/C_MessageEncryptNext but that is
    not made explicit in the text and perhaps is not true otherwise I would
    have expected the function to take a CKM_MECHANISM_TYPE parameter
    instead of CKM_MECHANISM_PTR, some text either way would be nice.
    So the information shouldn't be in C_MessageEncryptInit, but in the mechanisms itself. We should be explicit in the mechanisms. Some mechanisms may have a mechanism parameter in both C_MessageEncryptInit and a different one in C_EncryptMessage/C_EncryptMessageBegin/C_messageEncryptNext.


    If pParameter can be not null then the specific mechanisms implementing
    CKF_MESSAGE_ENCRYPT etc should specify it which brings me to AES GCM
    which is the only mechanism I looked into so far.
    yes, AES GCM, AES CCM and CHACHA_POLY should have explicit descriptions that the C_MessageEncryptInit parameter should be NULL (or whatever we believe the proper value should be).

    2) In "6.13 Additional AES Mechanisms"
    I think the table should show EncryptMessage/DecryptMessage as
    supported Functions in an additional column

    Yes.


    3) In "6.13.2 AES-GCM Authenticated Encryption / Decryption"
    Under the "MessageEncrypt:" section the last bulle point says:
    "Call C_MessageEncryptFinal() to close the message decryption.

    Two problems:
    3.1) decryption should really be encryption
    yes,

    3.2) I think this bulle point should rather say that
    C_EncryptMessageNext() should be called with flags=CKF_END_OF_MESSAGE
    to complete the message, because C_MessageEncryptFinal() is used to
    terminate the whole message encryption operation not a single message.

    Hmm that's closes a single message, not the whole stream. Perhaps the wording of the previous bullet should be updated to:

    • Call and number of:

      • ??C_EncryptMessage(), or??

      • C_EncryptMessageBegin() followed by?? one or more?? C_EncryptMessageNext(), the last containing the CKF_END_OF_MESSAGE

      • ??The mechanism parameter is passed to all three of these functions.

    To make it clear you can call multiple messages in the single stream. You do need C_MessageEncryptFinal when you are done with the stream.


    Also, to your point 1) we can put the information that the parameter should be NULL for C_MessageEncryptInit here. We should carry these changes to Decrypt and AES_CCM and CHACHA_POLY.

    5) [uncertain] The two sections should probably be renamed:
    MessageEncrypt -> EncryptMessage
    MessageDecrypt -> DecryptMessage
    to aligne with the name of the function used for the individual message
    encryptions.

    Hopefully the changes I suggest should make it clear the original titles are correct. The should describe the entire MessageEncrypt/MessageDecrypt semantics.

    - CKG_GENERATE_COUNTER_XOR means that the non-fixed portion of the IV
    is xored with a counter. The value of the non-fixed portion passed must
    not vary from call to call.

    Does this mean that the fixed portion can vary?
    We can discuss this, but there isn't a reason it can't (from a security point of view). All the security evaluation assumes that the non-fixed portion completely controls the uniqueness safety of the operation. The xor counter case is special because the non-fixed portion is now depended on the counter and the iv value. If the applications varies the non-fixed portion, then it can interfere with uniqueness guarantees. OTOH do we know of any cases where this value is varied in a stream? If not then the suggested description by Simo below is reasonable.
    Or should this say that
    the input IV should not vary from call to call ? Perhaps it should be
    made clear if the generated IV is returned in pIV for these calls
    because it would then tell the application developer whether they need
    to actively save the IV in a separate buffer for each call (or not).

    bob






  • 3.  RE: MessageEncrypt related editorial comments

    Posted 09-12-2024 13:02

    • Call and number of:

      • ??C_EncryptMessage(), or??

      • C_EncryptMessageBegin() followed by?? one or more?? C_EncryptMessageNext(), the last containing the CKF_END_OF_MESSAGE

      • ??The mechanism parameter is passed to all three of these functions.

    So ignore all those question marks thunderbird and the OASIS tools don't seem to like each other. Chock up yet another misfeature of our new OASIS tools! In the future if you see ?? by me, That's most likely the case.

    bob






  • 4.  RE: MessageEncrypt related editorial comments

    Posted 09-16-2024 09:41

    With regards to

    2) In "6.13 Additional AES Mechanisms"
    I think the table should show EncryptMessage/DecryptMessage as
    supported Functions in an additional column

    I agree that adding an addtl. column for message functions is a good idea.

    I have a concern from an editorial perspective though: When adding the new column "Encapsulate&Decapsulate" I already ran into some challenges with tables with long mechanism names. Adding yet another column will result in more line breaks in mechanism names and make them less readable.

    I can give it a try. In case the result is not satisfactory, would adding a note to mechanisms supporting message functions be good enough?

    Thanks,

    Dieter 



    ------------------------------
    Dieter Bong
    Manager Standardization and Strategic Projects
    Utimaco IS GmbH
    ------------------------------