Commit 1ec5de8d authored by garciay's avatar garciay
Browse files

Add Certificate support

parent 7ddb861d
Loading
Loading
Loading
Loading
+7 −7
Original line number Original line Diff line number Diff line
@@ -31,7 +31,7 @@ module LibItsSecurity_Pixits {
    /**
    /**
     * @desc TODO
     * @desc TODO
     */
     */
    modulepar octetstring PX_ECDSA_S := '00008A08AE40EC69030C056E48152F7A14F72BA4F305C2E6AA31997ABE93E7FD3D07E43400F68D98EEDB3B5A64FF49177ED6C484D94A596CD5CB2A5209B2A26CCDF8'O;
    modulepar octetstring PX_ECDSA_S                := '00008A08AE40EC69030C056E48152F7A14F72BA4F305C2E6AA31997ABE93E7FD'O;
    
    
    /**
    /**
     * @desc TODO
     * @desc TODO
+64 −100
Original line number Original line Diff line number Diff line
@@ -9,19 +9,15 @@ module LibItsSecurity_Templates {
    
    
    // LibCommon
    // LibCommon
    import from LibCommon_BasicTypesAndValues {
    import from LibCommon_BasicTypesAndValues {
        type 
		type UInt8, Int13, UInt16, UInt32, Int32;
            UInt8, Int13, UInt16, UInt32, 
            Int32 
	}
	}
    import from LibCommon_DataStrings {
    import from LibCommon_DataStrings {
        type 
		type Oct2, Oct12, Oct20, Oct0to31, Bit2, Bit3;
            Oct2, Oct12, Oct20, Oct0to31, 
            Bit2, Bit3
	}
	}


    
    
    // LibItsSecurity
    // LibItsSecurity
    import from LibItsSecurity_TypesAndValues all;
    import from LibItsSecurity_TypesAndValues {type all;}
    import from LibItsSecurity_Pixits all;
    import from LibItsSecurity_Pixits all;
    
    
    /**
    /**
@@ -74,75 +70,12 @@ module LibItsSecurity_Templates {
        group dummyBasicFormatElementsSend {
        group dummyBasicFormatElementsSend {
            
            
            /**
            /**
             * @desc Generic Send/Receive templates for security algorithm descriptions
             */
             */
            group dummyAlgorithms {
            group dummyAlgorithms {
                
                
                /**
                 * @desc Generic send template for EccPoint description
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.5   EccPoint
                 * @see Draft ETSI TS 103 097 V1.1.6 Table 2: Derivation of field sizes depending on the used algorithm
                 */
                template (value) EccPoint m_eccPoint_dummy := { 
                    algorithm       := e_ecdsa_nistp256_with_sha256,
                    field_size      := f_int2UInt8(1 + lengthof(PX_ECDSA_X_COORDINATE)), 
                    type_           := e_x_coordinate_only,
                    x               := PX_ECDSA_X_COORDINATE,
                    y               := omit
                } // End of template m_eccPoint_dummy
                
                /**
                 * @desc Generic send template for AES CCM description
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.5   EccPoint
                 * @see Draft ETSI TS 103 097 V1.1.6 Table 2: Derivation of field sizes depending on the used algorithm
                 */
                template (value) EccPoint m_aesccm_dummy := { 
                    algorithm       := e_ecies_nistp256,
                    field_size      := f_int2UInt8(1 + lengthof(PX_AESCCM_X_COORDINATE)), 
                    type_           := e_uncompressed,
                    x               := PX_AESCCM_X_COORDINATE,
                    y               := {
                        y := PX_AESCCM_Y_COORDINATE // WARNING siseof(y) == siseof(x)
                    } // End of field y
                } // End of template m_aesccm_dummy
                                
                /**
                 * @desc Generic send template for AES CCM encryption parameters
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.7    EncryptionParameters
                 */
                template (value) EncryptionParameters m_encryptionParameters_dummy := {
                    symm_algorithm := e_aes_128_ccm,
                    public_key := {
                        nonce := PX_AESCCM_NONCE
                    }
                } // End of template m_encryptionParameters_dummy
                
            } // End of group dummyAlgorithms
            } // End of group dummyAlgorithms
            
            
            /**
             * @desc Dummy send template for PublicKey/EccPoint
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.4    PublicKey
             */
            template (value) PublicKey m_publicKey_eccPoint_dummy := {
                algorithm   := e_ecdsa_nistp256_with_sha256,
                public_key  := {
                    eccPoint := m_eccPoint_dummy
                } // End of field public_key
            } // End of template PublicKey
            
            /**
             * @desc Dummy send template for PublicKey/AES CCM
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.4    PublicKey
             */
            template (value) PublicKey m_publicKey_aesccm_dummy := {
                algorithm   := e_ecies_nistp256,
                public_key  := {
                    aesCcm := {
                        supported_symm_alg  := e_aes_128_ccm,
                        eccPoint            := m_aesccm_dummy
                    } // End of field aesCcm
                } // End of field public_key
            } // End of template m_publicKey_aesccm_dummy
            
        } // End of group dummyBasicFormatElementsSend 
        } // End of group dummyBasicFormatElementsSend 
        
        
        /**
        /**
@@ -171,7 +104,7 @@ module LibItsSecurity_Templates {
                public_key  := {
                public_key  := {
                    aesCcm := ?
                    aesCcm := ?
                } // End of field public_key
                } // End of field public_key
            } // End of template m_publicKey_aesccm_dummy
            } // End of template mw_publicKey_aesccm_dummy
            
            
            /**
            /**
             * @desc Dummy receive template for Time64WithStandardDeviation
             * @desc Dummy receive template for Time64WithStandardDeviation
@@ -244,44 +177,57 @@ module LibItsSecurity_Templates {
        group basicFormatElementsSend {
        group basicFormatElementsSend {
            
            
            /**
            /**
             * @desc Send/Receive templates for security algorithm descriptions
             */
             */
            group algorithms {
            group algorithms {
                
                
                /**
                /**
                 * @desc Send template for EccPoint description
                 * @desc Send template for EccPoint description based on x_coordinate_only type
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.5   EccPoint
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.5   EccPoint
                 * @see Draft ETSI TS 103 097 V1.1.6 Table 2: Derivation of field sizes depending on the used algorithm
                 * @see Draft ETSI TS 103 097 V1.1.6 Table 2: Derivation of field sizes depending on the used algorithm
                 */
                 */
                template (value) EccPoint m_eccPointecdsa_nistp256_with_sha256_x_coordinate_only(
                template (value) EccPoint m_eccPointecdsa_nistp256_with_sha256_x_coordinate_only(
                                                                                                  in template (value) octetstring p_x
                                                                                                  in template (value) octetstring p_x
                ) modifies m_eccPoint_dummy := { 
                ) := { 
                    field_size      := f_int2UInt8(1 + lengthof(p_x)), 
                    type_           := e_x_coordinate_only,
                    x               := p_x
                    x               := p_x,
                    y               := omit
                } // End of template m_eccPointecdsa_nistp256_with_sha256_x_coordinate_only
                } // End of template m_eccPointecdsa_nistp256_with_sha256_x_coordinate_only
                
                
                /**
                /**
                 * @desc Send template for AES CCM description
                 * @desc Send template for EccPoint description based on uncompressed type
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.5   EccPoint
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.5   EccPoint
                 * @see Draft ETSI TS 103 097 V1.1.6 Table 2: Derivation of field sizes depending on the used algorithm
                 * @see Draft ETSI TS 103 097 V1.1.6 Table 2: Derivation of field sizes depending on the used algorithm
                 */
                 */
                template (value) EccPoint m_aesccm_ecies_nistp256_uncompressed(
                template (value) EccPoint m_eccPointecdsa_nistp256_with_sha256_uncompressed(
                                                                                            in template (value) octetstring p_x,
                                                                                            in template (value) octetstring p_x,
                                                                                            in template (value) octetstring p_y
                                                                                            in template (value) octetstring p_y
                ) modifies m_aesccm_dummy := { 
                ) := {
                    field_size      := f_int2UInt8(1 + lengthof(p_x)), 
                    type_           := e_uncompressed,
                    x               := p_x,
                    x               := p_x,
                    y               := {
                    y               := {
                        y := p_y
                        y := p_y
                    } // End of field y
                    }
                } // End of template m_aesccm_ecies_nistp256_uncompressed
                } // End of template m_eccPointecdsa_nistp256_with_sha256_uncompressed
                
                
                /**
                /**
                 * @desc Generic send template for AES CCM encryption parameters
                 * @desc Information regarding AES CCM encryption
                 * @param p_eccPoint   The EccPoint used in the PublicKey
                 */
                template (value) AesCcm m_aesccm(
                                                 in template (value) EccPoint p_eccPoint
                ) := {
                    supported_symm_alg  := e_aes_128_ccm,
                    eccPoint            := p_eccPoint
                } // End of template m_aesccm
                
                /**
                 * @desc Send template for AES CCM encryption parameters
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.7    EncryptionParameters
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.7    EncryptionParameters
                 */
                 */
                template (value) EncryptionParameters m_encryptionParameters_aes_128_ccm(
                template (value) EncryptionParameters m_encryptionParameters_aes_128_ccm(
                                                                                         in template (value) Oct12 p_nonce
                                                                                         in template (value) Oct12 p_nonce
                ) modifies m_encryptionParameters_dummy := {
                ) := {
                    symm_algorithm := e_aes_128_ccm,
                    symm_algorithm := e_aes_128_ccm,
                    public_key := {
                    public_key := {
                        nonce := p_nonce
                        nonce := p_nonce
@@ -290,6 +236,32 @@ module LibItsSecurity_Templates {
                
                
            } // End of group algorithms
            } // End of group algorithms
            
            
            /**
             * @desc Send template for PublicKey/EccPoint
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.4    PublicKey
             */
            template (value) PublicKey m_publicKey_eccPoint(
                                                            in template (value) EccPoint p_eccPoint
            ) := {
                algorithm   := e_ecdsa_nistp256_with_sha256,
                public_key  := {
                    eccPoint := p_eccPoint
                } // End of field public_key
            } // End of template m_publicKey_eccPoint
            
            /**
             * @desc Send template for PublicKey/AES CCM
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.4    PublicKey
             */
            template (value) PublicKey m_publicKey_aesccm(
                                                          in template (value) AesCcm p_aesCcm
            ) := {
                algorithm   := e_ecies_nistp256,
                public_key  := {
                    aesCcm := p_aesCcm
                } // End of field public_key
            } // End of template m_publicKey_aesccm
            
            /**
            /**
             * @desc Send/receive templates for Signature description
             * @desc Send/receive templates for Signature description
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.9   Signature
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.9   Signature
@@ -299,7 +271,6 @@ module LibItsSecurity_Templates {
                
                
                /**
                /**
                 * @desc Send template for signatures based on ECDSA algorithm
                 * @desc Send template for signatures based on ECDSA algorithm
                 * @member algorithm        Algorithm type
                 * @member p_ecdsaSignature The ECDSA based signature
                 * @member p_ecdsaSignature The ECDSA based signature
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.9   Signature
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.9   Signature
                 */
                 */
@@ -314,7 +285,6 @@ module LibItsSecurity_Templates {
                
                
                /**
                /**
                 * @desc Send template for ECDSA based signature
                 * @desc Send template for ECDSA based signature
                 * @member algorithm    Algorithm type
                 * @member p_r          The coordinate of the elliptic curve point resulting from multiplying the generator element by the ephemeral private key
                 * @member p_r          The coordinate of the elliptic curve point resulting from multiplying the generator element by the ephemeral private key
                 * @member p_s          The signature
                 * @member p_s          The signature
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.10   EcdsaSignature
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.10   EcdsaSignature
@@ -323,8 +293,6 @@ module LibItsSecurity_Templates {
                                                                 in template (value) EccPoint p_r,
                                                                 in template (value) EccPoint p_r,
                                                                 in template (value) octetstring p_s
                                                                 in template (value) octetstring p_s
                ) := {
                ) := {
                    algorithm   := e_ecdsa_nistp256_with_sha256,
                    field_size  := f_int2UInt8(1 + lengthof(p_s)),
                    r           := p_r,
                    r           := p_r,
                    s           := p_s
                    s           := p_s
                } // End of template m_ecdsaSignature
                } // End of template m_ecdsaSignature
@@ -711,8 +679,6 @@ module LibItsSecurity_Templates {
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.9 EciesEncryptedKey
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.9 EciesEncryptedKey
                 */
                 */
                template (present) EciesEncryptedKey mw_eciesEncryptedKey_dummy := {
                template (present) EciesEncryptedKey mw_eciesEncryptedKey_dummy := {
                    symm_alg        := ?,
                    symm_key_len    := ?,
                    v               := ?,
                    v               := ?,
                    c               := ?,
                    c               := ?,
                    t               := ?
                    t               := ?
@@ -1214,6 +1180,7 @@ module LibItsSecurity_Templates {
            
            
                /**
                /**
                 * @desc Send template for an ECIES-encrypted symmetric key as defined in IEEE Std 1363a 2004 
                 * @desc Send template for an ECIES-encrypted symmetric key as defined in IEEE Std 1363a 2004 
                 * @param p_ecc_key             The sender's EEC ephemeral key
                 * @param p_encrypted_key       The encrypted (AES) key 
                 * @param p_encrypted_key       The encrypted (AES) key 
                 * @param p_authentication_tag  The authentication tag vector
                 * @param p_authentication_tag  The authentication tag vector
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.9 EciesEncryptedKey
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.9 EciesEncryptedKey
@@ -1223,8 +1190,6 @@ module LibItsSecurity_Templates {
                                                                              in template (value) octetstring p_encrypted_key, 
                                                                              in template (value) octetstring p_encrypted_key, 
                                                                              in template (value) Oct20 p_authentication_tag
                                                                              in template (value) Oct20 p_authentication_tag
                ) := {
                ) := {
                    symm_alg        := e_aes_128_ccm,
                    symm_key_len    := f_int2UInt32(1 + lengthof(p_encrypted_key)),
                    v               := p_ecc_key,
                    v               := p_ecc_key,
                    c               := p_encrypted_key,
                    c               := p_encrypted_key,
                    t               := p_authentication_tag
                    t               := p_authentication_tag
@@ -1232,6 +1197,7 @@ module LibItsSecurity_Templates {
                
                
            /**
            /**
             * @desc Receive template for an ECIES-encrypted symmetric key as defined in IEEE Std 1363a 2004 
             * @desc Receive template for an ECIES-encrypted symmetric key as defined in IEEE Std 1363a 2004 
             * @param p_ecc_key             The sender's EEC ephemeral key
             * @param p_encrypted_key       The encrypted (AES) key 
             * @param p_encrypted_key       The encrypted (AES) key 
             * @param p_authentication_tag  The authentication tag vector
             * @param p_authentication_tag  The authentication tag vector
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.9 EciesEncryptedKey
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.9 EciesEncryptedKey
@@ -1241,8 +1207,6 @@ module LibItsSecurity_Templates {
                                                                             in template (present) octetstring p_encrypted_key, 
                                                                             in template (present) octetstring p_encrypted_key, 
                                                                             in template (present) Oct20 p_authentication_tag
                                                                             in template (present) Oct20 p_authentication_tag
            ) := {
            ) := {
                symm_alg        := e_aes_128_ccm,
                symm_key_len    := ?,
                v               := p_ecc_key,
                v               := p_ecc_key,
                c               := p_encrypted_key,
                c               := p_encrypted_key,
                t               := p_authentication_tag
                t               := p_authentication_tag
+17 −27
Original line number Original line Diff line number Diff line
@@ -57,16 +57,6 @@ module LibItsSecurity_TypesAndValues {
            PublicKeyContainer  public_key
            PublicKeyContainer  public_key
        } // End of type PublicKey
        } // End of type PublicKey
        
        
        /**
         * @desc Information regarding AES CCM encryption
         * @member supported_symm_alg   The symmetric key algorithm
         * @member eccPoint             The EccPoint used in the PublicKey
         */
        type record AesCcm {
            SymmetricAlgorithm  supported_symm_alg,
            EccPoint            eccPoint
        } // End of typAesCcmsc
        
        /**
        /**
         * @desc Information regarding ECC contained in an EccPoint structure
         * @desc Information regarding ECC contained in an EccPoint structure
         * @member eccPoint         Specific details regarding ECC contained in an EccPoint structure
         * @member eccPoint         Specific details regarding ECC contained in an EccPoint structure
@@ -79,10 +69,20 @@ module LibItsSecurity_TypesAndValues {
            octetstring     other_key
            octetstring     other_key
        } // End of type PublicKeyContainer
        } // End of type PublicKeyContainer
        
        
        /**
         * @desc Information regarding AES CCM encryption
         * @member supported_symm_alg   The symmetric key algorithm
         * @member eccPoint             The EccPoint used in the PublicKey
         */
        type record AesCcm {
            SymmetricAlgorithm  supported_symm_alg,
            EccPoint            eccPoint
        } // End of type AesCcmsc
        
        /**
        /**
         * @desc Defines public key based on elliptic curve cryptography
         * @desc Defines public key based on elliptic curve cryptography
         * @member algorithm    Specifying the used algorithm 
//         * @member algorithm    Specifying the used algorithm 
         * @member field_size   The lengths of the vectors containing the raw keys 
//         * @member field_size   The lengths of the vectors containing the raw keys 
         * @member type_        The ECC key types
         * @member type_        The ECC key types
         * @member x            The x coordinate 
         * @member x            The x coordinate 
         * @member y            The y coordinate
         * @member y            The y coordinate
@@ -91,8 +91,6 @@ module LibItsSecurity_TypesAndValues {
         * @see Draft ETSI TS 103 097 V1.1.6 Table 2: Derivation of field sizes depending on the used algorithm
         * @see Draft ETSI TS 103 097 V1.1.6 Table 2: Derivation of field sizes depending on the used algorithm
         */
         */
        type record EccPoint {
        type record EccPoint {
            PublicKeyAlgorithm  algorithm,
            UInt8               field_size,
            EccPointType        type_,
            EccPointType        type_,
            octetstring         x,
            octetstring         x,
            EccPointContainer   y optional
            EccPointContainer   y optional
@@ -150,7 +148,7 @@ module LibItsSecurity_TypesAndValues {
         * @desc Signatures based on public key cryptography
         * @desc Signatures based on public key cryptography
         * @member algorithm    Algorithm type
         * @member algorithm    Algorithm type
         * @member signature_   The signature
         * @member signature_   The signature
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.7   EncryptionParameters
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.9   Signature
         */
         */
        type record Signature {
        type record Signature {
            PublicKeyAlgorithm  algorithm,
            PublicKeyAlgorithm  algorithm,
@@ -169,15 +167,11 @@ module LibItsSecurity_TypesAndValues {
        
        
        /**
        /**
         * @desc Description an ECDSA based signature
         * @desc Description an ECDSA based signature
         * @member algorithm    
         * @member field_size   The 's' field length derived from the applied ECDSA algorithm 
         * @member r            Coordinate of the elliptic curve point resulting from multiplying the generator element by the ephemeral private key
         * @member r            Coordinate of the elliptic curve point resulting from multiplying the generator element by the ephemeral private key
         * @member s            
         * @member s            TODO
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.10  EcdsaSignature
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.10  EcdsaSignature
         */
         */
        type record EcdsaSignature {
        type record EcdsaSignature {
            PublicKeyAlgorithm  algorithm,
            UInt8               field_size,
            EccPoint            r,
            EccPoint            r,
            octetstring         s
            octetstring         s
        } // End of type EcdsaSignature
        } // End of type EcdsaSignature
@@ -548,16 +542,12 @@ module LibItsSecurity_TypesAndValues {
        
        
        /**
        /**
         * @desc Defines an ECIES-encrypted symmetric key as defined in IEEE Std 1363a 2004 
         * @desc Defines an ECIES-encrypted symmetric key as defined in IEEE Std 1363a 2004 
         * @member symm_alg     The algorithm 
         * @member symm_key_len The length of vector c containing the encrypted (AES) key 
         * @member v            The sender's ECC ephemeral key used for the Elliptic Curve Encryption Scheme
         * @member v            The sender's ECC ephemeral key used for the Elliptic Curve Encryption Scheme
         * @member c            The encrypted (AES) key 
         * @member c            The encrypted (AES) key 
         * @member t            The authentication tag vector
         * @member t            The authentication tag vector
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.9 EciesEncryptedKey
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.9 EciesEncryptedKey
         */
         */
         type record EciesEncryptedKey {
         type record EciesEncryptedKey {
            SymmetricAlgorithm   symm_alg,
            UInt32               symm_key_len,
            EccPoint             v,
            EccPoint             v,
            octetstring          c,
            octetstring          c,
            Oct20                t
            Oct20                t
@@ -659,8 +649,8 @@ module LibItsSecurity_TypesAndValues {
            e_encryption_key        (1),
            e_encryption_key        (1),
            e_assurance_level       (2),
            e_assurance_level       (2),
            e_reconstruction_value  (3),
            e_reconstruction_value  (3),
            e_its_aid_list          (4),
            e_its_aid_list          (32),
            e_its_aid_ssp_list      (5)
            e_its_aid_ssp_list      (33)
        } with { variant "8 bit" }
        } with { variant "8 bit" }
        
        
        /**
        /**
@@ -675,7 +665,7 @@ module LibItsSecurity_TypesAndValues {
            Bit3    levels,
            Bit3    levels,
            Bit3    reserved,
            Bit3    reserved,
            Bit2    confidence
            Bit2    confidence
        } // End of type SubjectAssurance
        } with { variant "8 bit" } // End of type SubjectAssurance
        
        
        /**
        /**
         * @desc Defines ways to restrict the validity restriction of the certificate
         * @desc Defines ways to restrict the validity restriction of the certificate