Commit a6ac0912 authored by garciay's avatar garciay
Browse files

STF538: Finalise certificates generation ATS

parent 37abbaa5
Loading
Loading
Loading
Loading
+106 −2
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ module LibItsSecurity_Functions {
        /**
         * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signature
         * @param   p_toBeSignedSecuredMessage    The data to be signed
         * @param   p_privateKey                  The private key
         * @return  The signature value
         */
        function f_signWithEcdsaBrainpoolp256WithSha256(
@@ -90,6 +91,7 @@ module LibItsSecurity_Functions {
        /**
         * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signature
         * @param   p_toBeSignedSecuredMessage    The data to be signed
         * @param   p_privateKey                  The private key
         * @return  The signature value
         */
        function f_signWithEcdsaBrainpoolp384WithSha384(
@@ -103,6 +105,90 @@ module LibItsSecurity_Functions {
            
        } // End of function f_signWithEcdsaBrainpoolp384WithSha384
        
        function f_decrypt(
                           in EtsiTs103097Data    p_encrypedSecuredMessage,
                           out EtsiTs103097Data   p_decrypedSecuredMessage
        ) return boolean {
            if (not(ischosen(p_encrypedSecuredMessage.content.encryptedData))) {
                var PKRecipientInfo v_pKRecipientInfo;
                var RecipientInfo v_recipientInfo := p_encrypedSecuredMessage.content.encryptedData.recipients[0];
                
                if (ischosen(v_recipientInfo.certRecipInfo)) {
                    v_pKRecipientInfo := p_encrypedSecuredMessage.content.encryptedData.recipients[0].certRecipInfo;
                    // Read the certificate based on the recipientId
                } else if (ischosen(v_recipientInfo.signedDataRecipInfo)) {
                    v_pKRecipientInfo := p_encrypedSecuredMessage.content.encryptedData.recipients[0].signedDataRecipInfo;
                    // Read the certificate based on the recipientId
                } else {
                    return false;
                }
                
                /*if (ischosen(v_pKRecipientInfo.encKey.eciesNistP256)) {
                    var octetstring v_encryptedSecuredMessage;
                    var SymmetricCiphertext v_ciphertext := p_encrypedSecuredMessage.content.encryptedData.ciphertext;
                    f_decryptWithEciesNistp256WithSha256(
                                                      v_ciphertext.aes128ccm.ccmCiphertext,
                                                      ,
                                                      ,
                                                      v_pKRecipientInfo.encKey.eciesNistP256.c,
                                                      v_ciphertext.aes128ccm.nonce,
                                                      v_pKRecipientInfo.encKey.eciesNistP256.t); 
                } else if (ischosen(v_pKRecipientInfo.encKey.eciesBrainpoolP256r1)) {
                }*/
            }
            
            return false;
        } // End of function f_signWithEcdsaBrainpoolp384WithSha384
        
        /**
         * @desc    Produces a Elliptic Curve Digital Encrytion Algorithm (ECIES) encryption
         * @param   p_toBeEncryptedSecuredMessage    The data to be encrypted
         * @return  The encrypted value
         */
        function f_encryptWithEciesNistp256WithSha256(
                                                      in octetstring p_toBeEncryptedSecuredMessage,
                                                      in Oct32 p_peerPublicKeyX,
                                                      in Oct32 p_peerPublicKeyY,
                                                      out Oct32 p_publicEncKeyX, 
                                                      out Oct32 p_publicEncKeyY,
                                                      out Oct16 p_ephKey,
                                                      out Oct16 p_tag,
                                                      out Oct12 p_nonce
        ) return octetstring {
            return fx_encryptWithEciesNistp256WithSha256(
                p_toBeEncryptedSecuredMessage, 
                p_peerPublicKeyX,
                p_peerPublicKeyY,
                p_publicEncKeyX,
                p_publicEncKeyY,
                p_ephKey,
                p_tag,
                p_nonce
            );
        } // End of function f_encryptWithEciesNistp256WithSha256
        
        /**
         * @desc    Produces a Elliptic Curve Digital Encrytion Algorithm (ECIES) decryption
         * @param   p_encryptedSecuredMessage    The data to be decrypted
         * @return  The decrypted value
         */
        function f_decryptWithEciesNistp256WithSha256(
                                                      in octetstring p_encryptedSecuredMessage,
                                                      in Oct32 p_publicKeyX,
                                                      in Oct32 p_publicKeyY,
                                                      in Oct12 p_nonce,
                                                      in Oct12 p_tag                                                      
        ) return octetstring {
            return fx_decryptWithEciesNistp256WithSha256(
                p_encryptedSecuredMessage,
                p_publicKeyX, 
                p_publicKeyY, 
                p_nonce, 
                p_tag
            );
            
        } // End of function f_decryptWithEcdsaNistp256WithSha256
        
        /**
         * @desc Compute the HashedId8 value from the hash value
         * @param p_hash The hash value
@@ -1668,6 +1754,24 @@ module LibItsSecurity_Functions {
             */
            external function fx_signWithEcdsaNistp256WithSha256(in Oct32 p_toBeSignedSecuredMessage, in Oct32 p_privateKey) return octetstring;
            
            /**
             * @desc    Produces a Elliptic Curve Digital Encrytion Algorithm (ECIES) encryption
             * @param   p_toBeEncryptedSecuredMessage    The data to be encrypted
             * @param   p_publicKeyX                     The public key (X coordonate)
             * @param   p_publicKeyY                     The public key (Y coordonate)
             * @return  The encrypted value
             */
            external function fx_encryptWithEciesNistp256WithSha256(in octetstring p_toBeEncryptedSecuredMessage, in Oct32 p_peerPublicKeyX, in Oct32 p_peerPublicKeyY, out Oct32 p_publicEncKeyX, out Oct32 p_publicEncKeyY, out Oct16 p_ephKey, out Oct16 p_tag, out Oct12 p_nonce) return octetstring;
            
            /**
             * @desc    Produces a Elliptic Curve Digital Encrytion Algorithm (ECIES) decryption
             * @param   p_encryptedSecuredMessage        The data to be decrypted
             * @param   p_publicKeyX                     The public key (X coordonate)
             * @param   p_publicKeyY                     The public key (Y coordonate)
             * @return  The decrypted value
             */
            external function fx_decryptWithEciesNistp256WithSha256(in octetstring p_encryptedSecuredMessage, in Oct32 p_publicKeyX, in Oct32 p_publicKeyY, in Oct12 p_nonce, in Oct12 p_tag) return octetstring;
            
            /**
             * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signature
             * @param   p_toBeSignedSecuredMessage    The data to be signed
@@ -1760,7 +1864,7 @@ module LibItsSecurity_Functions {
            * @return  true on success, false otherwise
            */
            external function fx_loadCertificates(in charstring p_rootDirectory, in charstring p_configId) return boolean;
            external function fx_store_certificate(in charstring p_cert_id, in octetstring p_cert, in octetstring p_private_key, in octetstring p_public_key_x, in octetstring p_public_key_y, in octetstring p_hashid8, in octetstring p_issuer) return boolean;
            external function fx_store_certificate(in charstring p_cert_id, in octetstring p_cert, in octetstring p_private_key, in octetstring p_public_key_x, in octetstring p_public_key_y, in octetstring p_hashid8, in octetstring p_issuer, in template (omit) octetstring p_private_enc_key, in template (omit) octetstring p_public_enc_key_x, in template (omit) octetstring p_public_enc_key_y) return boolean;
            
            /**
            * @desc    Unload from memory cache the certificates
+1 −1
Original line number Diff line number Diff line
@@ -1623,7 +1623,7 @@ module LibItsSecurity_Templates {
    group encryptionKey {
        
        template (value) PublicEncryptionKey m_encryptionKey(
                                                             in template (value) SymmAlgorithm p_supportedSymmAlg,
                                                             in template (value) SymmAlgorithm p_supportedSymmAlg := aes128Ccm,
                                                             in template (value) BasePublicEncryptionKey p_publicKey
        ) := { 
            supportedSymmAlg := p_supportedSymmAlg,