Commit 0972821f authored by garciay's avatar garciay
Browse files

Add Brainpool Security support

parent ef0c952b
Loading
Loading
Loading
Loading
+106 −18
Original line number Original line Diff line number Diff line
@@ -86,6 +86,22 @@ module LibItsSecurity_Functions {
            
            
        } // End of function f_signWithEcdsaBrainpoolp256WithSha256
        } // End of function f_signWithEcdsaBrainpoolp256WithSha256
        
        
        /**
         * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signature
         * @param   p_toBeSignedSecuredMessage    The data to be signed
         * @return  The signature value
         */
        function f_signWithEcdsaBrainpoolp384WithSha384(
                                                        in octetstring p_toBeSignedSecuredMessage,
                                                        in Oct48 p_privateKey
        ) runs on ItsSecurityBaseComponent return octetstring {
            return fx_signWithEcdsaBrainpoolp384WithSha384(
                p_toBeSignedSecuredMessage,
                p_privateKey
            );
            
        } // End of function f_signWithEcdsaBrainpoolp384WithSha384
        
        /**
        /**
         * @desc Compute the HashedId8 value from the hash value
         * @desc Compute the HashedId8 value from the hash value
         * @param p_hash The hash value
         * @param p_hash The hash value
@@ -136,6 +152,58 @@ module LibItsSecurity_Functions {
                p_ecdsaNistp256PublicKeyY);
                p_ecdsaNistp256PublicKeyY);
        } // End of function f_verifyWithEcdsaNistp256WithSha256
        } // End of function f_verifyWithEcdsaNistp256WithSha256
        
        
        /**
         * @Desc    Verify the signature of the specified data
         * @param   p_toBeVerifiedData          The data to be verified
         * @param   p_signature                 The signature
         * @param   p_ecdsaBrainpoolp256PublicKeyX   The public key (x coordinate)
         * @param   p_ecdsaBrainpoolp256PublicKeyY   The public key (y coordinate)
         * @return  true on success, false otherwise
         */
        function f_verifyWithEcdsaBrainpoolp256WithSha256(
                                                          in octetstring p_toBeVerifiedData,
                                                          in octetstring p_signature,
                                                          in octetstring p_ecdsaBrainpoolp256PublicKeyX,
                                                          in octetstring p_ecdsaBrainpoolp256PublicKeyY
        ) return boolean {
//            log("f_verifyWithEcdsaBrainpoolp256WithSha256: toBeVerifiedData", p_toBeVerifiedData);
//            log("f_verifyWithEcdsaBrainpoolp256WithSha256: toBeVerifiedData length", lengthof(p_toBeVerifiedData));
//            log("f_verifyWithEcdsaBrainpoolp256WithSha256: signature", p_signature);
//            log("f_verifyWithEcdsaBrainpoolp256WithSha256: ecdsaBrainpoolp256PublicKeyX", p_ecdsaBrainpoolp256PublicKeyX);
//            log("f_verifyWithEcdsaBrainpoolp256WithSha256: ecdsaBrainpoolp256PublicKeyY", p_ecdsaBrainpoolp256PublicKeyY);
            return fx_verifyWithEcdsaBrainpoolp256WithSha256(
                p_toBeVerifiedData,
                p_signature,
                p_ecdsaBrainpoolp256PublicKeyX,
                p_ecdsaBrainpoolp256PublicKeyY);
        } // End of function f_verifyWithEcdsaBrainpoolp256WithSha256
        
        /**
         * @Desc    Verify the signature of the specified data
         * @param   p_toBeVerifiedData          The data to be verified
         * @param   p_signature                 The signature
         * @param   p_ecdsaBrainpoolp384PublicKeyX   The public key (x coordinate)
         * @param   p_ecdsaBrainpoolp384PublicKeyY   The public key (y coordinate)
         * @return  true on success, false otherwise
         */
        function f_verifyWithEcdsaBrainpoolp384WithSha384(
                                                          in octetstring p_toBeVerifiedData,
                                                          in octetstring p_signature,
                                                          in octetstring p_ecdsaBrainpoolp384PublicKeyX,
                                                          in octetstring p_ecdsaBrainpoolp384PublicKeyY
        ) return boolean {
//            log("f_verifyWithEcdsaBrainpoolp384WithSha384: toBeVerifiedData", p_toBeVerifiedData);
//            log("f_verifyWithEcdsaBrainpoolp384WithSha384: toBeVerifiedData length", lengthof(p_toBeVerifiedData));
//            log("f_verifyWithEcdsaBrainpoolp384WithSha384: signature", p_signature);
//            log("f_verifyWithEcdsaBrainpoolp384WithSha384: ecdsaBrainpoolp384PublicKeyX", p_ecdsaBrainpoolp384PublicKeyX);
//            log("f_verifyWithEcdsaBrainpoolp384WithSha384: ecdsaBrainpoolp384PublicKeyY", p_ecdsaBrainpoolp384PublicKeyY);
            return fx_verifyWithEcdsaBrainpoolp384WithSha384(
                p_toBeVerifiedData,
                p_signature,
                p_ecdsaBrainpoolp384PublicKeyX,
                p_ecdsaBrainpoolp384PublicKeyY);
        } // End of function f_verifyWithEcdsaBrainpoolp384WithSha384
        
        /**
        /**
         * @desc    Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm.
         * @desc    Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm.
         *          This function should not be used by the ATS
         *          This function should not be used by the ATS
@@ -145,9 +213,9 @@ module LibItsSecurity_Functions {
         * @return  true on success, false otherwise
         * @return  true on success, false otherwise
         */
         */
        function f_generate_key_pair_nistp256(
        function f_generate_key_pair_nistp256(
                                              out octetstring p_privateKey,
                                              out Oct32 p_privateKey,
                                              out octetstring p_publicKeyX,
                                              out Oct32 p_publicKeyX,
                                              out octetstring p_publicKeyY
                                              out Oct32 p_publicKeyY
                                             ) return boolean {
                                             ) return boolean {
          return fx_generateKeyPair_nistp256(p_privateKey, p_publicKeyX, p_publicKeyY);
          return fx_generateKeyPair_nistp256(p_privateKey, p_publicKeyX, p_publicKeyY);
        }
        }
@@ -161,9 +229,9 @@ module LibItsSecurity_Functions {
         * @return  true on success, false otherwise
         * @return  true on success, false otherwise
         */
         */
        function f_generate_key_pair_brainpoolp256(
        function f_generate_key_pair_brainpoolp256(
                                                   out octetstring p_privateKey,
                                                   out Oct32 p_privateKey,
                                                   out octetstring p_publicKeyX,
                                                   out Oct32 p_publicKeyX,
                                                   out octetstring p_publicKeyY
                                                   out Oct32 p_publicKeyY
                                                  ) return boolean {
                                                  ) return boolean {
          return fx_generateKeyPair_brainpoolp256(p_privateKey, p_publicKeyX, p_publicKeyY);
          return fx_generateKeyPair_brainpoolp256(p_privateKey, p_publicKeyX, p_publicKeyY);
        }
        }
@@ -177,9 +245,9 @@ module LibItsSecurity_Functions {
         * @return  true on success, false otherwise
         * @return  true on success, false otherwise
         */
         */
        function f_generate_key_pair_brainpoolp384(
        function f_generate_key_pair_brainpoolp384(
                                                   out octetstring p_privateKey,
                                                   out Oct48 p_privateKey,
                                                   out octetstring p_publicKeyX,
                                                   out Oct48 p_publicKeyX,
                                                   out octetstring p_publicKeyY
                                                   out Oct48 p_publicKeyY
                                                  ) return boolean {
                                                  ) return boolean {
          return fx_generateKeyPair_brainpoolp384(p_privateKey, p_publicKeyX, p_publicKeyY);
          return fx_generateKeyPair_brainpoolp384(p_privateKey, p_publicKeyX, p_publicKeyY);
        }
        }
@@ -1479,14 +1547,14 @@ module LibItsSecurity_Functions {
             * @param   p_toBeHashedData Data to be used to calculate the hash value
             * @param   p_toBeHashedData Data to be used to calculate the hash value
             * @return  The hash value
             * @return  The hash value
             */
             */
            external function fx_hashWithSha256(in octetstring p_toBeHashedData) return Oct32;
            external function fx_hashWithSha256(in Oct32 p_toBeHashedData) return Oct32;
            
            
            /**
            /**
             * @desc    Produces a 384-bit (48-byte) hash value
             * @desc    Produces a 384-bit (48-byte) hash value
             * @param   p_toBeHashedData Data to be used to calculate the hash value
             * @param   p_toBeHashedData Data to be used to calculate the hash value
             * @return  The hash value
             * @return  The hash value
             */
             */
            external function fx_hashWithSha384(in octetstring p_toBeHashedData) return Oct48;
            external function fx_hashWithSha384(in Oct32 p_toBeHashedData) return Oct48;
            
            
            /**
            /**
             * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signature
             * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signature
@@ -1494,7 +1562,7 @@ module LibItsSecurity_Functions {
             * @param   p_privateKey        The private key
             * @param   p_privateKey        The private key
             * @return  The signature value
             * @return  The signature value
             */
             */
            external function fx_signWithEcdsaNistp256WithSha256(in octetstring p_toBeSignedSecuredMessage, in octetstring/*UInt64*/ p_privateKey) return octetstring;
            external function fx_signWithEcdsaNistp256WithSha256(in Oct32 p_toBeSignedSecuredMessage, in Oct32 p_privateKey) return octetstring;


            /**
            /**
             * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signature
             * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signature
@@ -1502,7 +1570,7 @@ module LibItsSecurity_Functions {
             * @param   p_privateKey        The private key
             * @param   p_privateKey        The private key
             * @return  The signature value
             * @return  The signature value
             */
             */
            external function fx_signWithEcdsaBrainpoolp256WithSha256(in octetstring p_toBeSignedSecuredMessage, in octetstring/*UInt64*/ p_privateKey) return octetstring;
            external function fx_signWithEcdsaBrainpoolp256WithSha256(in Oct32 p_toBeSignedSecuredMessage, in Oct32 p_privateKey) return octetstring;
            
            
            /**
            /**
             * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signature
             * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signature
@@ -1510,7 +1578,7 @@ module LibItsSecurity_Functions {
             * @param   p_privateKey        The private key
             * @param   p_privateKey        The private key
             * @return  The signature value
             * @return  The signature value
             */
             */
            external function fx_signWithEcdsaBrainpoolp384WithSha384(in octetstring p_toBeSignedSecuredMessage, in octetstring/*UInt64*/ p_privateKey) return octetstring;
            external function fx_signWithEcdsaBrainpoolp384WithSha384(in Oct48 p_toBeSignedSecuredMessage, in Oct48 p_privateKey) return octetstring;
            
            
            /**
            /**
             * @desc    Verify the signature of the specified data
             * @desc    Verify the signature of the specified data
@@ -1520,7 +1588,27 @@ module LibItsSecurity_Functions {
             * @param   p_ecdsaNistp256PublicKeyY   The public key (y coordinate)
             * @param   p_ecdsaNistp256PublicKeyY   The public key (y coordinate)
             * @return  true on success, false otherwise
             * @return  true on success, false otherwise
             */
             */
            external function fx_verifyWithEcdsaNistp256WithSha256(in octetstring p_toBeVerifiedData, in octetstring p_signature, in octetstring p_ecdsaNistp256PublicKeyX, in octetstring p_ecdsaNistp256PublicKeyY) return boolean;
            external function fx_verifyWithEcdsaNistp256WithSha256(in Oct32 p_toBeVerifiedData, in octetstring p_signature, in Oct32 p_ecdsaNistp256PublicKeyX, in Oct32 p_ecdsaNistp256PublicKeyY) return boolean;
            
            /**
             * @desc    Verify the signature of the specified data
             * @param   p_toBeVerifiedData          The data to be verified
             * @param   p_signature                 The signature
             * @param   p_ecdsaBrainpoolp256PublicKeyX   The public key (x coordinate)
             * @param   p_ecdsaBrainpoolp256PublicKeyY   The public key (y coordinate)
             * @return  true on success, false otherwise
             */
            external function fx_verifyWithEcdsaBrainpoolp256WithSha256(in Oct32 p_toBeVerifiedData, in octetstring p_signature, in Oct32 p_ecdsaBrainpoolp256PublicKeyX, in Oct32 p_ecdsaBrainpoolp256PublicKeyY) return boolean;
            
            /**
             * @desc    Verify the signature of the specified data
             * @param   p_toBeVerifiedData          The data to be verified
             * @param   p_signature                 The signature
             * @param   p_ecdsaBrainpoolp384PublicKeyX   The public key (x coordinate)
             * @param   p_ecdsaBrainpoolp384PublicKeyY   The public key (y coordinate)
             * @return  true on success, false otherwise
             */
            external function fx_verifyWithEcdsaBrainpoolp384WithSha384(in Oct48 p_toBeVerifiedData, in octetstring p_signature, in Oct48 p_ecdsaBrainpoolp384PublicKeyX, in Oct48 p_ecdsaBrainpoolp384PublicKeyY) return boolean;
            
            
            /**
            /**
             * @desc    Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm.
             * @desc    Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm.
@@ -1530,7 +1618,7 @@ module LibItsSecurity_Functions {
             * @param   p_publicKeyX    The new public key value (y coordinate)
             * @param   p_publicKeyX    The new public key value (y coordinate)
             * @return  true on success, false otherwise
             * @return  true on success, false otherwise
             */
             */
            external function fx_generateKeyPair_nistp256(out octetstring/*UInt64*/ p_privateKey, out octetstring p_publicKeyX, out octetstring p_publicKeyY) return boolean;
            external function fx_generateKeyPair_nistp256(out Oct32 p_privateKey, out Oct32 p_publicKeyX, out Oct32 p_publicKeyY) return boolean;
            
            
            /**
            /**
             * @desc    Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm.
             * @desc    Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm.
@@ -1540,7 +1628,7 @@ module LibItsSecurity_Functions {
             * @param   p_publicKeyX    The new public key value (y coordinate)
             * @param   p_publicKeyX    The new public key value (y coordinate)
             * @return  true on success, false otherwise
             * @return  true on success, false otherwise
             */
             */
            external function fx_generateKeyPair_brainpoolp256(out octetstring/*UInt64*/ p_privateKey, out octetstring p_publicKeyX, out octetstring p_publicKeyY) return boolean;
            external function fx_generateKeyPair_brainpoolp256(out Oct32 p_privateKey, out Oct32 p_publicKeyX, out Oct32 p_publicKeyY) return boolean;
            
            
            /**
            /**
             * @desc    Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm.
             * @desc    Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm.
@@ -1550,7 +1638,7 @@ module LibItsSecurity_Functions {
             * @param   p_publicKeyX    The new public key value (y coordinate)
             * @param   p_publicKeyX    The new public key value (y coordinate)
             * @return  true on success, false otherwise
             * @return  true on success, false otherwise
             */
             */
            external function fx_generateKeyPair_brainpoolp384(out octetstring/*UInt64*/ p_privateKey, out octetstring p_publicKeyX, out octetstring p_publicKeyY) return boolean;
            external function fx_generateKeyPair_brainpoolp384(out Oct48 p_privateKey, out Oct48 p_publicKeyX, out Oct48 p_publicKeyY) return boolean;
            
            
        } // End of group signing
        } // End of group signing