Commit 722f77d8 authored by garciay's avatar garciay
Browse files

STF545: Validate ECIES implementation

parent 284ecb2d
Loading
Loading
Loading
Loading
+51 −22
Original line number Original line Diff line number Diff line
@@ -123,18 +123,27 @@ module LibItsSecurity_Functions {
                    return false;
                    return false;
                }
                }
                
                
                /*if (ischosen(v_pKRecipientInfo.encKey.eciesNistP256)) {
                if (ischosen(v_pKRecipientInfo.encKey.eciesNistP256)) {
                    var octetstring v_encryptedSecuredMessage;
                  var octetstring v_decryptedSecuredMessage;
                  var SymmetricCiphertext v_ciphertext := p_encrypedSecuredMessage.content.encryptedData.ciphertext;
                  var SymmetricCiphertext v_ciphertext := p_encrypedSecuredMessage.content.encryptedData.ciphertext;
                    f_decryptWithEciesNistp256WithSha256(
                  // FIXME Add the private encryption key
                  /*v_decryptedSecuredMessage := f_decryptWithEciesNistp256WithSha256(
                                                                                    v_ciphertext.aes128ccm.ccmCiphertext,
                                                                                    v_ciphertext.aes128ccm.ccmCiphertext,
                                                      ,
                                                                                    v_pKRecipientInfo.encKey.eciesNistP256.v.uncompressedP256.x,
                                                      ,
                                                                                    v_pKRecipientInfo.encKey.eciesNistP256.v.uncompressedP256.y,
                                                                                    v_pKRecipientInfo.encKey.eciesNistP256.c,
                                                                                    v_pKRecipientInfo.encKey.eciesNistP256.c,
                                                      v_ciphertext.aes128ccm.nonce,
                                                                                    v_pKRecipientInfo.encKey.eciesNistP256.t,
                                                      v_pKRecipientInfo.encKey.eciesNistP256.t); 
                                                                                    v_ciphertext.aes128ccm.nonce
                } else if (ischosen(v_pKRecipientInfo.encKey.eciesBrainpoolP256r1)) {
                                                                                    );
                  if (isbound(v_decryptedSecuredMessage)) {
                    var bitstring v_decode := oct2bit(v_decryptedSecuredMessage);
                    if (decvalue(v_decode, p_decrypedSecuredMessage) == 0) {
                      return true;
                    }
                    }*/
                    }*/
                } else if (ischosen(v_pKRecipientInfo.encKey.eciesBrainpoolP256r1)) {
                  // TODO
                }
            }
            }
            
            
            return false;
            return false;
@@ -143,7 +152,14 @@ module LibItsSecurity_Functions {
        /**
        /**
         * @desc    Produces a Elliptic Curve Digital Encrytion Algorithm (ECIES) encryption
         * @desc    Produces a Elliptic Curve Digital Encrytion Algorithm (ECIES) encryption
         * @param   p_toBeEncryptedSecuredMessage    The data to be encrypted
         * @param   p_toBeEncryptedSecuredMessage    The data to be encrypted
         * @return  The encrypted value
         * @param   p_recipientsPublicKeyX           The Recipient's public encryption key X-coordinate
         * @param   p_recipientsPublicKeyY           The Recipient's public encryption key Y-coordinate
         * @param   p_publicEphemeralKeyX            The generated ephemeral key X-coordinate
         * @param   p_publicEphemeralKeyY            The generated ephemeral key Y-coordinate
         * @param   p_encrypted_sym_key              The encrypted AES 128 CCM symmetric key
         * @param   p_authentication_vector          The tag of the AES 128 CCM symmetric key encryption
         * @param   p_nonce                          The nonce vector of the AES 128 CCM symmetric key encryption
         * @return  The encrypted message
         */
         */
        function f_encryptWithEciesNistp256WithSha256(
        function f_encryptWithEciesNistp256WithSha256(
                                                      in octetstring p_toBeEncryptedSecuredMessage,
                                                      in octetstring p_toBeEncryptedSecuredMessage,
@@ -170,7 +186,12 @@ module LibItsSecurity_Functions {
        /**
        /**
         * @desc    Produces a Elliptic Curve Digital Encrytion Algorithm (ECIES) decryption
         * @desc    Produces a Elliptic Curve Digital Encrytion Algorithm (ECIES) decryption
         * @param   p_encryptedSecuredMessage    The data to be decrypted
         * @param   p_encryptedSecuredMessage    The data to be decrypted
         * @return  The decrypted value
         * @param   p_publicEphemeralKeyX            The generated ephemeral key X-coordinate
         * @param   p_publicEphemeralKeyY            The generated ephemeral key Y-coordinate
         * @param   p_encrypted_sym_key              The encrypted AES 128 CCM symmetric key
         * @param   p_authentication_vector          The tag of the AES 128 CCM symmetric key encryption
         * @param   p_nonce                          The nonce vector of the AES 128 CCM symmetric key encryption
         * @return  The decrypted message
         */
         */
        function f_decryptWithEciesNistp256WithSha256(
        function f_decryptWithEciesNistp256WithSha256(
                                                      in octetstring p_encryptedSecuredMessage,
                                                      in octetstring p_encryptedSecuredMessage,
@@ -1782,18 +1803,26 @@ module LibItsSecurity_Functions {
            /**
            /**
             * @desc    Produces a Elliptic Curve Digital Encrytion Algorithm (ECIES) encryption
             * @desc    Produces a Elliptic Curve Digital Encrytion Algorithm (ECIES) encryption
             * @param   p_toBeEncryptedSecuredMessage    The data to be encrypted
             * @param   p_toBeEncryptedSecuredMessage    The data to be encrypted
             * @param   p_publicKeyX                     The public key (X coordonate)
             * @param   p_recipientsPublicKeyX           The Recipient's public encryption key X-coordinate
             * @param   p_publicKeyY                     The public key (Y coordonate)
             * @param   p_recipientsPublicKeyY           The Recipient's public encryption key Y-coordinate
             * @return  The encrypted value
             * @param   p_publicEphemeralKeyX            The generated ephemeral key X-coordinate
             * @param   p_publicEphemeralKeyY            The generated ephemeral key Y-coordinate
             * @param   p_encrypted_sym_key              The encrypted AES 128 CCM symmetric key
             * @param   p_authentication_vector          The tag of the AES 128 CCM symmetric key encryption
             * @param   p_nonce                          The nonce vector of the AES 128 CCM symmetric key encryption
             * @return  The encrypted message
             */
             */
            external function fx_encryptWithEciesNistp256WithSha256(in octetstring p_toBeEncryptedSecuredMessage, in Oct32 p_recipientsPublicKeyX, in Oct32 p_recipientsPublicKeyY, out Oct32 p_publicEphemeralKeyX, out Oct32 p_publicEphemeralKeyY, out Oct16 p_encrypted_sym_key, out Oct16 p_authentication_vector, out Oct12 p_nonce) return octetstring;
            external function fx_encryptWithEciesNistp256WithSha256(in octetstring p_toBeEncryptedSecuredMessage, in Oct32 p_recipientsPublicKeyX, in Oct32 p_recipientsPublicKeyY, out Oct32 p_publicEphemeralKeyX, out Oct32 p_publicEphemeralKeyY, out Oct16 p_encrypted_sym_key, out Oct16 p_authentication_vector, out Oct12 p_nonce) return octetstring;
            
            
            /**
            /**
             * @desc    Produces a Elliptic Curve Digital Encrytion Algorithm (ECIES) decryption
             * @desc    Produces a Elliptic Curve Digital Encrytion Algorithm (ECIES) decryption
             * @param   p_encryptedSecuredMessage    The data to be decrypted
             * @param   p_encryptedSecuredMessage    The data to be decrypted
             * @param   p_publicKeyX                     The public key (X coordonate)
             * @param   p_publicEphemeralKeyX            The generated ephemeral key X-coordinate
             * @param   p_publicKeyY                     The public key (Y coordonate)
             * @param   p_publicEphemeralKeyY            The generated ephemeral key Y-coordinate
             * @return  The decrypted value
             * @param   p_encrypted_sym_key              The encrypted AES 128 CCM symmetric key
             * @param   p_authentication_vector          The tag of the AES 128 CCM symmetric key encryption
             * @param   p_nonce                          The nonce vector of the AES 128 CCM symmetric key encryption
             * @return  The decrypted message
             */
             */
            external function fx_decryptWithEciesNistp256WithSha256(in octetstring p_encryptedSecuredMessage, in Oct32 p_privateEncKey, in Oct32 p_publicEphemeralKeyX, in Oct32 p_publicEphemeralKeyY, in Oct16 p_encrypted_sym_key, in Oct16 p_authentication_vector, in Oct12 p_nonce) return octetstring;
            external function fx_decryptWithEciesNistp256WithSha256(in octetstring p_encryptedSecuredMessage, in Oct32 p_privateEncKey, in Oct32 p_publicEphemeralKeyX, in Oct32 p_publicEphemeralKeyY, in Oct16 p_encrypted_sym_key, in Oct16 p_authentication_vector, in Oct12 p_nonce) return octetstring;