Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TTCN-3 Libraries
LibIts
Compare Revisions
a4ba15561d9ac0e0d94098b5ddc3727f41f5981a...d7fb38fe273bdf9835b7ef676efb1b2b91b34af1
Commits (2)
AtsPki validation: major bugs fixed
· bbaa3f82
Yann Garcia
authored
Nov 22, 2018
bbaa3f82
AtsPki validation: major bugs fixed
· d7fb38fe
Yann Garcia
authored
Nov 22, 2018
d7fb38fe
Expand all
Hide whitespace changes
Inline
Side-by-side
ttcn/Http/LibItsHttp_TestSystem.ttcn
View file @
d7fb38fe
...
@@ -25,6 +25,7 @@ module LibItsHttp_TestSystem {
...
@@ -25,6 +25,7 @@ module LibItsHttp_TestSystem {
type
component
HttpComponent
extends
SelfSyncComp
{
// FIXME To be rename into HttpTest
type
component
HttpComponent
extends
SelfSyncComp
{
// FIXME To be rename into HttpTest
port
HttpPort
httpPort
;
port
HttpPort
httpPort
;
timer
tc_ac
:=
PX_TAC
;
timer
tc_ac
:=
PX_TAC
;
timer
tc_noac
:=
PX_TNOAC
;
}
// End of component HttpComponent
}
// End of component HttpComponent
type
component
HttpTestAdapter
{
// FIXME To be rename into HttpTestSystem
type
component
HttpTestAdapter
{
// FIXME To be rename into HttpTestSystem
...
...
ttcn/Pki/LibItsPki_Functions.ttcn
View file @
d7fb38fe
This diff is collapsed.
Click to expand it.
ttcn/Pki/LibItsPki_Pics.ttcn
View file @
d7fb38fe
...
@@ -38,7 +38,7 @@ module LibItsPki_Pics {
...
@@ -38,7 +38,7 @@ module LibItsPki_Pics {
/**
/**
* @desc Certificate used by the Test System acting as EA
* @desc Certificate used by the Test System acting as EA
*/
*/
modulepar
charstring
PICS_TS_EA_CERTIFICATE_ID
:=
"CERT_
TS_A_
EA"
;
modulepar
charstring
PICS_TS_EA_CERTIFICATE_ID
:=
"CERT_EA"
;
/**
/**
* @desc Certificate used by the Test System acting as AA
* @desc Certificate used by the Test System acting as AA
...
...
ttcn/Security/LibItsSecurity_Functions.ttcn
View file @
d7fb38fe
...
@@ -124,6 +124,7 @@ module LibItsSecurity_Functions {
...
@@ -124,6 +124,7 @@ module LibItsSecurity_Functions {
if
(
ischosen
(
p_encrypedSecuredMessage
.
content
.
encryptedData
))
{
if
(
ischosen
(
p_encrypedSecuredMessage
.
content
.
encryptedData
))
{
var
PKRecipientInfo
v_pKRecipientInfo
;
var
PKRecipientInfo
v_pKRecipientInfo
;
var
RecipientInfo
v_recipientInfo
:=
p_encrypedSecuredMessage
.
content
.
encryptedData
.
recipients
[
0
];
var
RecipientInfo
v_recipientInfo
:=
p_encrypedSecuredMessage
.
content
.
encryptedData
.
recipients
[
0
];
var
octetstring
v_decryptedSecuredMessage
;
// Check the private encryption key
// Check the private encryption key
if
(
not
(
isbound
(
p_encryptPrivateKey
)))
{
if
(
not
(
isbound
(
p_encryptPrivateKey
)))
{
...
@@ -142,8 +143,8 @@ module LibItsSecurity_Functions {
...
@@ -142,8 +143,8 @@ module LibItsSecurity_Functions {
return
false
;
return
false
;
}
}
if
(
isbound
(
v_pKRecipientInfo
))
{
if
(
ischosen
(
v_pKRecipientInfo
.
encKey
.
eciesNistP256
))
{
if
(
ischosen
(
v_pKRecipientInfo
.
encKey
.
eciesNistP256
))
{
var
octetstring
v_decryptedSecuredMessage
;
var
SymmetricCiphertext
v_ciphertext
:=
p_encrypedSecuredMessage
.
content
.
encryptedData
.
ciphertext
;
var
SymmetricCiphertext
v_ciphertext
:=
p_encrypedSecuredMessage
.
content
.
encryptedData
.
ciphertext
;
if
(
ischosen
(
v_pKRecipientInfo
.
encKey
.
eciesNistP256
.
v
.
compressed_y_0
))
{
if
(
ischosen
(
v_pKRecipientInfo
.
encKey
.
eciesNistP256
.
v
.
compressed_y_0
))
{
v_decryptedSecuredMessage
:=
f_decryptWithEciesNistp256WithSha256
(
v_decryptedSecuredMessage
:=
f_decryptWithEciesNistp256WithSha256
(
...
@@ -180,7 +181,6 @@ module LibItsSecurity_Functions {
...
@@ -180,7 +181,6 @@ module LibItsSecurity_Functions {
}
}
}
}
}
else
if
(
ischosen
(
v_pKRecipientInfo
.
encKey
.
eciesBrainpoolP256r1
))
{
}
else
if
(
ischosen
(
v_pKRecipientInfo
.
encKey
.
eciesBrainpoolP256r1
))
{
var
octetstring
v_decryptedSecuredMessage
;
var
SymmetricCiphertext
v_ciphertext
:=
p_encrypedSecuredMessage
.
content
.
encryptedData
.
ciphertext
;
var
SymmetricCiphertext
v_ciphertext
:=
p_encrypedSecuredMessage
.
content
.
encryptedData
.
ciphertext
;
if
(
ischosen
(
v_pKRecipientInfo
.
encKey
.
eciesBrainpoolP256r1
.
v
.
compressed_y_0
))
{
if
(
ischosen
(
v_pKRecipientInfo
.
encKey
.
eciesBrainpoolP256r1
.
v
.
compressed_y_0
))
{
v_decryptedSecuredMessage
:=
f_decryptWithEciesBrainpoolp256WithSha256
(
v_decryptedSecuredMessage
:=
f_decryptWithEciesBrainpoolp256WithSha256
(
...
@@ -206,6 +206,15 @@ module LibItsSecurity_Functions {
...
@@ -206,6 +206,15 @@ module LibItsSecurity_Functions {
log
(
"*** "
&
testcasename
()
&
":ERROR: Non canonical ephemeral encryption keys ***"
);
log
(
"*** "
&
testcasename
()
&
":ERROR: Non canonical ephemeral encryption keys ***"
);
return
false
;
return
false
;
}
}
}
else
{
log
(
"*** "
&
testcasename
()
&
":ERROR: Non canonical ephemeral encryption keys ***"
);
return
false
;
}
// TODO else, other variants shall be processed here if
}
else
{
log
(
"*** "
&
testcasename
()
&
":ERROR: Invalid recipient info ***"
);
return
false
;
}
if
(
isbound
(
v_decryptedSecuredMessage
))
{
if
(
isbound
(
v_decryptedSecuredMessage
))
{
var
bitstring
v_decode
:=
oct2bit
(
v_decryptedSecuredMessage
);
var
bitstring
v_decode
:=
oct2bit
(
v_decryptedSecuredMessage
);
if
(
decvalue
(
v_decode
,
p_decrypedSecuredMessage
)
==
0
)
{
if
(
decvalue
(
v_decode
,
p_decrypedSecuredMessage
)
==
0
)
{
...
@@ -214,7 +223,6 @@ module LibItsSecurity_Functions {
...
@@ -214,7 +223,6 @@ module LibItsSecurity_Functions {
log
(
"*** "
&
testcasename
()
&
":ERROR: Faild to decode secured message ***"
);
log
(
"*** "
&
testcasename
()
&
":ERROR: Faild to decode secured message ***"
);
}
}
}
}
}
}
else
{
}
else
{
log
(
"*** "
&
testcasename
()
&
":ERROR: Message not encrypted ***"
);
log
(
"*** "
&
testcasename
()
&
":ERROR: Message not encrypted ***"
);
}
}
...
@@ -244,9 +252,11 @@ module LibItsSecurity_Functions {
...
@@ -244,9 +252,11 @@ module LibItsSecurity_Functions {
in
octetstring
p_salt
,
in
octetstring
p_salt
,
out
Oct32
p_publicEphemeralKeyCompressed
,
out
Oct32
p_publicEphemeralKeyCompressed
,
out
integer
p_ephemeralKeyModeCompressed
,
out
integer
p_ephemeralKeyModeCompressed
,
out
Oct16
p_aes_sym_key
,
out
Oct16
p_encrypted_sym_key
,
out
Oct16
p_encrypted_sym_key
,
out
Oct16
p_authentication_vector
,
out
Oct16
p_authentication_vector
,
out
Oct12
p_nonce
out
Oct12
p_nonce
,
in
boolean
p_use_hardcoded_values
:=
false
)
return
octetstring
{
)
return
octetstring
{
return
fx_encryptWithEciesNistp256WithSha256
(
return
fx_encryptWithEciesNistp256WithSha256
(
p_toBeEncryptedSecuredMessage
,
p_toBeEncryptedSecuredMessage
,
...
@@ -255,9 +265,11 @@ module LibItsSecurity_Functions {
...
@@ -255,9 +265,11 @@ module LibItsSecurity_Functions {
p_salt
,
p_salt
,
p_publicEphemeralKeyCompressed
,
p_publicEphemeralKeyCompressed
,
p_ephemeralKeyModeCompressed
,
p_ephemeralKeyModeCompressed
,
p_aes_sym_key
,
p_encrypted_sym_key
,
p_encrypted_sym_key
,
p_authentication_vector
,
p_authentication_vector
,
p_nonce
p_nonce
,
p_use_hardcoded_values
);
);
}
// End of function f_encryptWithEciesNistp256WithSha256
}
// End of function f_encryptWithEciesNistp256WithSha256
...
@@ -317,6 +329,7 @@ module LibItsSecurity_Functions {
...
@@ -317,6 +329,7 @@ module LibItsSecurity_Functions {
in
integer
p_compressedMode
,
in
integer
p_compressedMode
,
out
Oct32
p_publicEphemeralKeyCompressed
,
out
Oct32
p_publicEphemeralKeyCompressed
,
out
integer
p_ephemeralKeyModeCompressed
,
out
integer
p_ephemeralKeyModeCompressed
,
out
Oct16
p_aes_sym_key
,
out
Oct16
p_encrypted_sym_key
,
out
Oct16
p_encrypted_sym_key
,
out
Oct16
p_authentication_vector
,
out
Oct16
p_authentication_vector
,
out
Oct12
p_nonce
out
Oct12
p_nonce
...
@@ -327,6 +340,7 @@ module LibItsSecurity_Functions {
...
@@ -327,6 +340,7 @@ module LibItsSecurity_Functions {
p_compressedMode
,
p_compressedMode
,
p_publicEphemeralKeyCompressed
,
p_publicEphemeralKeyCompressed
,
p_ephemeralKeyModeCompressed
,
p_ephemeralKeyModeCompressed
,
p_aes_sym_key
,
p_encrypted_sym_key
,
p_encrypted_sym_key
,
p_authentication_vector
,
p_authentication_vector
,
p_nonce
p_nonce
...
@@ -595,11 +609,11 @@ module LibItsSecurity_Functions {
...
@@ -595,11 +609,11 @@ module LibItsSecurity_Functions {
out
integer
p_compressedMode
out
integer
p_compressedMode
)
return
boolean
{
)
return
boolean
{
if
(
PICS_SEC_FIXED_KEYS
)
{
if
(
PICS_SEC_FIXED_KEYS
)
{
p_privateKey
:=
'
F8EB15C001A03623A5B5E44D73869621877710712A498C98FF9E60EE10F390F8
'
O
;
p_privateKey
:=
'
D418760F0CB2DCB856BC3C7217AD3AA36DB6742AE1DB655A3D28DF88CBBF84E1
'
O
;
p_publicKeyX
:=
'
7029
A9B20D22AE37B1344B7FCC2322C8F1E5ECE09C39CC289E500A9487298B9B
'
O
;
p_publicKeyX
:=
'
EE9CC7FBD9EDECEA41F7C8BD258E8D2E988E75BD069ADDCA1E5A38E534AC6818
'
O
;
p_publicKeyY
:=
'
F9EFA8BCC4129BC43B640566A59AE5CED7106BBA76E5DC828AF37D315634D3DC
'
O
;
p_publicKeyY
:=
'
5
AE3C8D9FE0B1FC7438F29417C240F8BF81C358EC1A4D0C6E98D8EDBCC714017
'
O
;
p_publicKeyCompressed
:=
'
7029
A9B20D22AE37B1344B7FCC2322C8F1E5ECE09C39CC289E500A9487298B9B
'
O
;
p_publicKeyCompressed
:=
'
EE9CC7FBD9EDECEA41F7C8BD258E8D2E988E75BD069ADDCA1E5A38E534AC6818
'
O
;
p_compressedMode
:=
0
;
p_compressedMode
:=
1
;
return
true
;
return
true
;
}
}
...
@@ -2332,9 +2346,9 @@ module LibItsSecurity_Functions {
...
@@ -2332,9 +2346,9 @@ module LibItsSecurity_Functions {
* @param p_nonce The nonce vector 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
* @return The encrypted message
*/
*/
external
function
fx_encryptWithEciesNistp256WithSha256
(
in
octetstring
p_toBeEncryptedSecuredMessage
,
in
Oct32
p_recipientsPublicKeyCompressed
,
in
integer
p_compressedMode
,
in
octetstring
p_salt
,
out
Oct32
p_publicEphemeralKeyCompressed
,
out
integer
p_ephemeralKeyModeCompressed
,
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_recipientsPublicKeyCompressed
,
in
integer
p_compressedMode
,
in
octetstring
p_salt
,
out
Oct32
p_publicEphemeralKeyCompressed
,
out
integer
p_ephemeralKeyModeCompressed
,
out
Oct16
p_aes_sym_key
,
out
Oct16
p_encrypted_sym_key
,
out
Oct16
p_authentication_vector
,
out
Oct12
p_nonce
,
in
boolean
p_use_hardcoded_values
:=
false
)
return
octetstring
;
external
function
fx_test_encryptWithEciesNistp256WithSha256
(
in
octetstring
p_toBeEncryptedSecuredMessage
,
in
Oct32
p_privateEphemeralKey
,
in
Oct32
p_recipientPublicKeyX
,
in
Oct32
p_recipientPublicKeyY
,
in
octetstring
p_salt
,
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_test_encryptWithEciesNistp256WithSha256
(
in
octetstring
p_toBeEncryptedSecuredMessage
,
in
Oct32
p_privateEphemeralKey
,
in
Oct32
p_recipientPublicKeyX
,
in
Oct32
p_recipientPublicKeyY
,
in
octetstring
p_salt
,
out
Oct32
p_publicEphemeralKeyX
,
out
Oct32
p_publicEphemeralKeyY
,
out
Oct16
p_aes_sym_key
,
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 using Nist-P256 algorithm
* @desc Produces a Elliptic Curve Digital Encrytion Algorithm (ECIES) decryption using Nist-P256 algorithm
* @param p_encryptedSecuredMessage The data to be decrypted
* @param p_encryptedSecuredMessage The data to be decrypted
...
@@ -2359,7 +2373,7 @@ module LibItsSecurity_Functions {
...
@@ -2359,7 +2373,7 @@ module LibItsSecurity_Functions {
* @param p_nonce The nonce vector 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
* @return The encrypted message
*/
*/
external
function
fx_encryptWithEciesBrainpoolp256WithSha256
(
in
octetstring
p_toBeEncryptedSecuredMessage
,
in
Oct32
p_recipientsPublicKeyCompressed
,
in
integer
p_compressedMode
,
out
Oct32
p_publicEphemeralKeyCompressed
,
out
integer
p_ephemeralKeyModeCompressed
,
out
Oct16
p_encrypted_sym_key
,
out
Oct16
p_authentication_vector
,
out
Oct12
p_nonce
)
return
octetstring
;
external
function
fx_encryptWithEciesBrainpoolp256WithSha256
(
in
octetstring
p_toBeEncryptedSecuredMessage
,
in
Oct32
p_recipientsPublicKeyCompressed
,
in
integer
p_compressedMode
,
out
Oct32
p_publicEphemeralKeyCompressed
,
out
integer
p_ephemeralKeyModeCompressed
,
out
Oct16
p_aes_sym_key
,
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 using Brainpool-P256 algorithm
* @desc Produces a Elliptic Curve Digital Encrytion Algorithm (ECIES) decryption using Brainpool-P256 algorithm
...
...
ttcn/Security/LibItsSecurity_Templates.ttcn
View file @
d7fb38fe
...
@@ -665,6 +665,12 @@ module LibItsSecurity_Templates {
...
@@ -665,6 +665,12 @@ module LibItsSecurity_Templates {
pskRecipInfo
:=
p_pskRecipInfo
pskRecipInfo
:=
p_pskRecipInfo
}
// End of template m_recipientInfo_pskRecipInfo
}
// End of template m_recipientInfo_pskRecipInfo
template
(
present
)
RecipientInfo
mw_recipientInfo_pskRecipInfo
(
template
(
present
)
PreSharedKeyRecipientInfo
p_pskRecipInfo
:=
?
)
:=
{
pskRecipInfo
:=
p_pskRecipInfo
}
// End of template mw_recipientInfo_pskRecipInfo
template
(
value
)
RecipientInfo
m_recipientInfo_symmRecipInfo
(
template
(
value
)
RecipientInfo
m_recipientInfo_symmRecipInfo
(
in
template
(
value
)
SymmRecipientInfo
p_symmRecipInfo
in
template
(
value
)
SymmRecipientInfo
p_symmRecipInfo
)
:=
{
)
:=
{
...
...