Commit d141b2b3 authored by garciay's avatar garciay
Browse files

Bug fixed on self signed certificate signature

parent 35202204
......@@ -91,7 +91,7 @@ module TestCodec_Certificates {
v_encMsg := encvalue(v_cert.toBeSigned);
// Sign the certificate using ECDSA/SHA-256 (NIST p-256)
// IEEE Std 1609.2-20XX Clause 5.3.1 ii) If the verification type is self-signed, signer identifier input shall be the empty string, i.e., a string of length 0.
v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_encMsg), int2oct(0, 32), v_private_key);
v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_encMsg), int2oct(0, 8), v_private_key);
if (lengthof(v_sig) != 64) {
log("Invalid signature: ", v_sig);
setverdict(fail);
......@@ -122,7 +122,7 @@ module TestCodec_Certificates {
}
if (f_verifyWithEcdsaNistp256WithSha256(
bit2oct(v_encMsg),
int2oct(0, 32),
int2oct(0, 8),
v_cert_dec.signature_.ecdsaNistP256Signature.rSig.x_only & v_cert_dec.signature_.ecdsaNistP256Signature.sSig,
v_publicKeyCompressed,
v_compressedMode
......@@ -193,7 +193,7 @@ module TestCodec_Certificates {
log("Encode template ", valueof(v_cert.toBeSigned));
v_encMsg := encvalue(v_cert.toBeSigned);
// Sign the certificate using ECDSA/SHA-256 (NIST p-256)
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(bit2oct(v_encMsg), int2oct(0, 32), v_private_key);
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(bit2oct(v_encMsg), int2oct(0, 8), v_private_key);
if (lengthof(v_sig) != 64) {
log("Invalid signature: ", v_sig);
setverdict(fail);
......@@ -224,7 +224,7 @@ module TestCodec_Certificates {
}
if (f_verifyWithEcdsaBrainpoolp256WithSha256(
bit2oct(v_encMsg),
int2oct(0, 32),
int2oct(0, 8),
v_cert_dec.signature_.ecdsaBrainpoolP256r1Signature.rSig.x_only & v_cert_dec.signature_.ecdsaBrainpoolP256r1Signature.sSig,
v_publicKeyCompressed,
v_compressedMode
......@@ -311,7 +311,7 @@ module TestCodec_Certificates {
log("Encode template ", valueof(v_cert.toBeSigned));
v_encMsg := encvalue(v_cert.toBeSigned);
// Sign the certificate using ECDSA/SHA-256 (NIST p-256)
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(bit2oct(v_encMsg), int2oct(0, 32), v_private_key);
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(bit2oct(v_encMsg), int2oct(0, 8), v_private_key);
if (lengthof(v_sig) != 64) {
log("Invalid signature: ", v_sig);
setverdict(fail);
......@@ -342,7 +342,7 @@ module TestCodec_Certificates {
}
if (f_verifyWithEcdsaBrainpoolp256WithSha256(
bit2oct(v_encMsg),
int2oct(0, 32),
int2oct(0, 8),
v_cert_dec.signature_.ecdsaBrainpoolP256r1Signature.rSig.x_only & v_cert_dec.signature_.ecdsaBrainpoolP256r1Signature.sSig,
v_publicKeyCompressed,
v_compressedMode
......@@ -413,7 +413,7 @@ module TestCodec_Certificates {
log("Encode template ", valueof(v_cert.toBeSigned));
v_encMsg := encvalue(v_cert.toBeSigned);
// Sign the certificate
v_sig := f_signWithEcdsaBrainpoolp384WithSha384(bit2oct(v_encMsg), int2oct(0, 48), v_private_key);
v_sig := f_signWithEcdsaBrainpoolp384WithSha384(bit2oct(v_encMsg), int2oct(0, 8), v_private_key);
if (lengthof(v_sig) != 96) {
log("Invalid signature: ", v_sig);
setverdict(fail);
......@@ -444,7 +444,7 @@ module TestCodec_Certificates {
}
if (f_verifyWithEcdsaBrainpoolp384WithSha384(
bit2oct(v_encMsg),
int2oct(0, 48),
int2oct(0, 8),
v_cert_dec.signature_.ecdsaBrainpoolP384r1Signature.rSig.x_only & v_cert_dec.signature_.ecdsaBrainpoolP384r1Signature.sSig,
v_publicKeyCompressed,
v_compressedMode
......@@ -511,7 +511,7 @@ module TestCodec_Certificates {
log("Encode template ", valueof(v_cert));
v_encMsg := encvalue(v_cert.toBeSigned);
// Sign the certificate using ECDSA/SHA-256 (NIST p-256)
v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_encMsg), int2oct(0, 32), v_private_key);
v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_encMsg), int2oct(0, 8), v_private_key);
if (lengthof(v_sig) != 64) {
log("Invalid signature: ", v_sig);
setverdict(fail);
......@@ -543,7 +543,7 @@ module TestCodec_Certificates {
}
if (f_verifyWithEcdsaNistp256WithSha256(
bit2oct(v_encMsg),
int2oct(0, 32),
int2oct(0, 8),
v_cert_dec.signature_.ecdsaNistP256Signature.rSig.x_only & v_cert_dec.signature_.ecdsaNistP256Signature.sSig,
v_publicKeyCompressed,
v_compressedMode
......@@ -609,7 +609,7 @@ module TestCodec_Certificates {
log("Encode template ", valueof(v_cert.toBeSigned));
v_encMsg := encvalue(v_cert.toBeSigned);
// Sign the certificate using ECDSA/SHA-256 (NIST p-256)
v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_encMsg), int2oct(0, 32), v_private_key);
v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_encMsg), int2oct(0, 8), v_private_key);
if (lengthof(v_sig) != 64) {
log("Invalid signature: ", v_sig);
setverdict(fail);
......@@ -639,7 +639,7 @@ module TestCodec_Certificates {
}
if (f_verifyWithEcdsaNistp256WithSha256(
bit2oct(v_encMsg),
int2oct(0, 32),
int2oct(0, 8),
v_cert_dec.signature_.ecdsaNistP256Signature.rSig.x_only & v_cert_dec.signature_.ecdsaNistP256Signature.sSig,
v_publicKeyCompressed,
v_compressedMode
......@@ -702,7 +702,7 @@ module TestCodec_Certificates {
log("Encode template ", valueof(v_cert.toBeSigned));
v_encMsg := encvalue(v_cert.toBeSigned);
// Sign the certificate using ECDSA/SHA-256 (BP p-256)
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(bit2oct(v_encMsg), int2oct(0, 32), v_private_key);
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(bit2oct(v_encMsg), int2oct(0, 8), v_private_key);
if (lengthof(v_sig) != 64) {
log("Invalid signature: ", v_sig);
setverdict(fail);
......@@ -732,7 +732,7 @@ module TestCodec_Certificates {
}
if (f_verifyWithEcdsaBrainpoolp256WithSha256(
bit2oct(v_encMsg),
int2oct(0, 32),
int2oct(0, 8),
v_cert_dec.signature_.ecdsaBrainpoolP256r1Signature.rSig.x_only & v_cert_dec.signature_.ecdsaBrainpoolP256r1Signature.sSig,
v_publicKeyCompressed,
v_compressedMode
......@@ -889,7 +889,7 @@ module TestCodec_Certificates {
// Create signature and compare with cprovide one
v_enc_msg := encvalue(v_cert_exp.toBeSigned);
v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_enc_msg), int2oct(0, 32), v_private_key);
v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_enc_msg), int2oct(0, 8), v_private_key);
if (not(match(v_sig, v_cert_dec.signature_.ecdsaNistP256Signature.rSig.x_only & v_cert_dec.signature_.ecdsaNistP256Signature.sSig))) {
setverdict(fail, "Signature generation mismatch");
} else {
......@@ -905,7 +905,7 @@ module TestCodec_Certificates {
}
if (f_verifyWithEcdsaNistp256WithSha256(
bit2oct(v_enc_msg),
int2oct(0, 32),
int2oct(0, 8),
v_cert_dec.signature_.ecdsaNistP256Signature.rSig.x_only & v_cert_dec.signature_.ecdsaNistP256Signature.sSig,
v_publicKeyCompressed,
v_compressedMode
......
......@@ -68,7 +68,7 @@ module TestCodec_ChainOfCertificates {
}
if (f_verifyWithEcdsaNistp256WithSha256(
bit2oct(v_enc_msg),
int2oct(0, 32),
int2oct(0, 8),
v_chain_sec_info.ca.cert.signature_.ecdsaNistP256Signature.rSig.x_only & v_chain_sec_info.ca.cert.signature_.ecdsaNistP256Signature.sSig,
v_publicKeyCompressed,
v_publicKeyCompressedMode
......@@ -96,7 +96,7 @@ module TestCodec_ChainOfCertificates {
}
if (f_verifyWithEcdsaNistp256WithSha256(
bit2oct(v_enc_msg),
f_hashWithSha256(v_chain_sec_info.ca.enc_cert),
v_chain_sec_info.ca.issuer,
v_chain_sec_info.aa.cert.signature_.ecdsaNistP256Signature.rSig.x_only & v_chain_sec_info.aa.cert.signature_.ecdsaNistP256Signature.sSig,
v_publicKeyCompressed,
v_publicKeyCompressedMode
......@@ -125,7 +125,7 @@ module TestCodec_ChainOfCertificates {
}
if (f_verifyWithEcdsaNistp256WithSha256(
bit2oct(v_enc_msg),
f_hashWithSha256(v_chain_sec_info.aa.enc_cert),
v_chain_sec_info.aa.issuer,
v_chain_sec_info.at.cert.signature_.ecdsaNistP256Signature.rSig.x_only & v_chain_sec_info.at.cert.signature_.ecdsaNistP256Signature.sSig,
v_publicKeyCompressed,
v_publicKeyCompressedMode
......@@ -176,7 +176,7 @@ module TestCodec_ChainOfCertificates {
}
if (f_verifyWithEcdsaNistp256WithSha256(
bit2oct(v_enc_msg),
f_hashWithSha256(v_chain_sec_info.at.enc_cert),
v_chain_sec_info.at.issuer,
valueof(v_secured_data.content.signedData.signature_.ecdsaNistP256Signature.rSig.x_only) & valueof(v_secured_data.content.signedData.signature_.ecdsaNistP256Signature.sSig),
v_publicKeyCompressed,
v_publicKeyCompressedMode
......@@ -220,7 +220,7 @@ module TestCodec_ChainOfCertificates {
}
if (f_verifyWithEcdsaBrainpoolp256WithSha256(
bit2oct(v_enc_msg),
int2oct(0, 32),
int2oct(0, 8),
v_chain_sec_info.ca.cert.signature_.ecdsaBrainpoolP256r1Signature.rSig.x_only & v_chain_sec_info.ca.cert.signature_.ecdsaBrainpoolP256r1Signature.sSig,
v_publicKeyCompressed,
v_publicKeyCompressedMode
......@@ -247,7 +247,7 @@ module TestCodec_ChainOfCertificates {
}
if (f_verifyWithEcdsaBrainpoolp256WithSha256(
bit2oct(v_enc_msg),
f_hashWithSha256(v_chain_sec_info.ca.enc_cert),
v_chain_sec_info.ca.issuer,
v_chain_sec_info.aa.cert.signature_.ecdsaBrainpoolP256r1Signature.rSig.x_only & v_chain_sec_info.aa.cert.signature_.ecdsaBrainpoolP256r1Signature.sSig,
v_publicKeyCompressed,
v_publicKeyCompressedMode
......@@ -274,7 +274,7 @@ module TestCodec_ChainOfCertificates {
}
if (f_verifyWithEcdsaBrainpoolp256WithSha256(
bit2oct(v_enc_msg),
f_hashWithSha256(v_chain_sec_info.aa.enc_cert),
v_chain_sec_info.aa.issuer,
v_chain_sec_info.at.cert.signature_.ecdsaBrainpoolP256r1Signature.rSig.x_only & v_chain_sec_info.at.cert.signature_.ecdsaBrainpoolP256r1Signature.sSig,
v_publicKeyCompressed,
v_publicKeyCompressedMode
......@@ -323,7 +323,7 @@ module TestCodec_ChainOfCertificates {
}
if (f_verifyWithEcdsaBrainpoolp256WithSha256(
bit2oct(v_enc_msg),
f_hashWithSha256(v_chain_sec_info.at.enc_cert),
v_chain_sec_info.at.issuer,
valueof(v_secured_data.content.signedData.signature_.ecdsaBrainpoolP256r1Signature.rSig.x_only) & valueof(v_secured_data.content.signedData.signature_.ecdsaBrainpoolP256r1Signature.sSig),
v_publicKeyCompressed,
v_publicKeyCompressedMode
......@@ -395,7 +395,7 @@ module TestCodec_ChainOfCertificates {
// Encode it ==> Get octetstring
v_enc_msg := encvalue(valueof(v_cert.toBeSigned));
// Sign the certificate using ECDSA/SHA-256 (NIST p-256)
v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_enc_msg), int2oct(0, 32), p_ca_sec_info.private_key);
v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_enc_msg), int2oct(0, 8), p_ca_sec_info.private_key);
v_cert.signature_ := m_signature_ecdsaNistP256(
m_ecdsaP256Signature(
m_eccP256CurvePoint_x_only(
......@@ -465,7 +465,7 @@ module TestCodec_ChainOfCertificates {
// Encode it ==> Get octetstring
v_enc_msg := encvalue(v_cert.toBeSigned);
// Sign the certificate using ECDSA/SHA-256 (BRAINPOOL P-256)
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(bit2oct(v_enc_msg), int2oct(0, 32), p_ca_sec_info.private_key);
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(bit2oct(v_enc_msg), int2oct(0, 8), p_ca_sec_info.private_key);
v_cert.signature_ := m_signature_ecdsaBrainpoolP256r1(
m_ecdsaP256Signature(
m_eccP256CurvePoint_x_only(
......@@ -531,7 +531,7 @@ module TestCodec_ChainOfCertificates {
// Encode it ==> Get octetstring
v_enc_msg := encvalue(v_cert.toBeSigned);
// Sign the certificate using ECDSA/SHA-256 (NIST P-256)
v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_enc_msg), f_hashWithSha256(p_ca_sec_info.enc_cert), p_ca_sec_info.private_key);
v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_enc_msg), p_ca_sec_info.issuer, p_ca_sec_info.private_key);
v_cert.signature_ := m_signature_ecdsaNistP256(
m_ecdsaP256Signature(
m_eccP256CurvePoint_x_only(
......@@ -597,7 +597,7 @@ module TestCodec_ChainOfCertificates {
// Encode it ==> Get octetstring
v_enc_msg := encvalue(v_cert.toBeSigned);
// Sign the certificate using ECDSA/SHA-256 (BRAINPOOL P-256)
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(bit2oct(v_enc_msg), f_hashWithSha256(p_ca_sec_info.enc_cert), p_ca_sec_info.private_key);
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(bit2oct(v_enc_msg), p_ca_sec_info.issuer, p_ca_sec_info.private_key);
v_cert.signature_ := m_signature_ecdsaBrainpoolP256r1(
m_ecdsaP256Signature(
m_eccP256CurvePoint_x_only(
......@@ -664,7 +664,7 @@ module TestCodec_ChainOfCertificates {
log("Encode template ", valueof(v_cert));
v_enc_msg := encvalue(v_cert.toBeSigned);
// Sign the certificate using ECDSA/SHA-256 (NIST P-256)
v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_enc_msg), f_hashWithSha256(p_aa_sec_info.enc_cert), p_aa_sec_info.private_key);
v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_enc_msg), p_aa_sec_info.issuer, p_aa_sec_info.private_key);
v_cert.signature_ := m_signature_ecdsaNistP256(
m_ecdsaP256Signature(
m_eccP256CurvePoint_x_only(
......@@ -731,7 +731,7 @@ module TestCodec_ChainOfCertificates {
log("Encode template ", valueof(v_cert));
v_enc_msg := encvalue(v_cert.toBeSigned);
// Sign the certificate using ECDSA/SHA-256 (BRAINPOOL P-256)
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(bit2oct(v_enc_msg), f_hashWithSha256(p_aa_sec_info.enc_cert), p_aa_sec_info.private_key);
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(bit2oct(v_enc_msg), p_aa_sec_info.issuer, p_aa_sec_info.private_key);
v_cert.signature_ := m_signature_ecdsaBrainpoolP256r1(
m_ecdsaP256Signature(
m_eccP256CurvePoint_x_only(
......@@ -768,7 +768,7 @@ module TestCodec_ChainOfCertificates {
);
// Signed it
v_raw_payload_to_be_signed := bit2oct(encvalue(v_toBeSignedData));
v_sig := f_signWithEcdsaNistp256WithSha256(v_raw_payload_to_be_signed, f_hashWithSha256(p_at_sec_info.enc_cert), p_at_sec_info.private_key);
v_sig := f_signWithEcdsaNistp256WithSha256(v_raw_payload_to_be_signed, p_at_sec_info.issuer, p_at_sec_info.private_key);
// Finalize the secured message
v_secured_data := valueof(
m_etsiTs103097Data_signed(
......@@ -814,7 +814,7 @@ module TestCodec_ChainOfCertificates {
);
// Signed it
v_raw_payload_to_be_signed := bit2oct(encvalue(v_toBeSignedData));
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_raw_payload_to_be_signed, f_hashWithSha256(p_at_sec_info.enc_cert), p_at_sec_info.private_key);
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_raw_payload_to_be_signed, p_at_sec_info.issuer, p_at_sec_info.private_key);
// Finalize the secured message
v_secured_data := m_etsiTs103097Data_signed(
m_signedData(
......
......@@ -125,6 +125,20 @@ module TestCodec_SecuredFuntions {
}
} // End of testcase tc_sha256_1
testcase tc_sha256_2() runs on TCType system TCType {
var octetstring v_test := ''O;
var Oct32 v_exp_hash := 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'O; /* Hash of empty string */
var Oct32 v_hash;
v_hash := f_hashWithSha256(v_test);
if (match(v_hash, v_exp_hash) == false) {
setverdict(fail);
} else {
setverdict(pass);
}
} // End of testcase tc_sha256_2
testcase tc_sha384_1() runs on TCType system TCType {
var octetstring v_test := '616263'O;
var Oct48 v_exp_hash := 'CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7'O;
......@@ -139,6 +153,20 @@ module TestCodec_SecuredFuntions {
}
} // End of testcase tc_sha384_1
testcase tc_sha384_2() runs on TCType system TCType {
var octetstring v_test := ''O;
var Oct48 v_exp_hash := '38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b'O; /* Hash of empty string */
var Oct48 v_hash;
v_hash := f_hashWithSha384(v_test);
if (match(v_hash, v_exp_hash) == false) {
setverdict(fail);
} else {
setverdict(pass);
}
} // End of testcase tc_sha384_2
testcase tc_f_generate_key_pair_1() runs on TCType system TCType {
var Oct32 v_private_key;
var Oct32 v_publicKeyX;
......@@ -214,7 +242,7 @@ module TestCodec_SecuredFuntions {
log("v_public_key Y= ", v_publicKeyY);
log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
v_sig := f_signWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key);
v_sig := f_signWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 8), v_private_key);
if (lengthof(v_sig) == 0) {
setverdict(fail);
stop;
......@@ -241,18 +269,18 @@ module TestCodec_SecuredFuntions {
log("v_public_key Y= ", v_publicKeyY);
log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
v_sig := f_signWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key);
v_sig := f_signWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 8), v_private_key);
if (lengthof(v_sig) == 0) {
setverdict(fail);
stop;
}
if (f_verifyWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
if (f_verifyWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
setverdict(fail);
} else {
setverdict(pass);
}
if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == false) {
if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyX, v_publicKeyY) == false) {
setverdict(fail);
} else {
setverdict(pass);
......@@ -280,18 +308,18 @@ module TestCodec_SecuredFuntions {
v_private_key_wrong := v_private_key;
v_sig := f_signWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key);
v_sig := f_signWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 8), v_private_key);
if (lengthof(v_sig) == 0) {
setverdict(fail);
stop;
}
if (f_verifyWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
if (f_verifyWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
setverdict(fail);
} else {
setverdict(pass);
}
if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == false) {
if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyX, v_publicKeyY) == false) {
setverdict(fail);
stop;
} else {
......@@ -299,13 +327,14 @@ module TestCodec_SecuredFuntions {
}
v_private_key_wrong[2] := 'AA'O;
v_sig := f_signWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key_wrong);
if (f_verifyWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyCompressed, v_compressedMode) == true) {
v_private_key_wrong[3] := 'BB'O;
v_sig := f_signWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 8), v_private_key_wrong);
if (f_verifyWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyCompressed, v_compressedMode) == true) {
setverdict(fail);
} else {
setverdict(pass);
}
if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == true) {
if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyX, v_publicKeyY) == true) {
setverdict(fail);
} else {
setverdict(pass);
......@@ -333,42 +362,42 @@ module TestCodec_SecuredFuntions {
log("v_public_key Y= ", v_publicKeyY);
log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
v_sig := f_signWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key);
if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == false) {
v_sig := f_signWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 8), v_private_key);
if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyX, v_publicKeyY) == false) {
setverdict(fail);
stop;
}
if (f_verifyWithEcdsaNistp256WithSha256_1('0A0A0A0A'O, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == true) {
if (f_verifyWithEcdsaNistp256WithSha256_1('0A0A0A0A'O, int2oct(10, 8), v_sig, v_publicKeyX, v_publicKeyY) == true) {
setverdict(fail);
stop;
}
v_sig_wrong := v_sig;
v_sig_wrong[0] := 'FF'O;
if (f_verifyWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_sig_wrong, v_publicKeyCompressed, v_compressedMode) == true) {
if (f_verifyWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 8), v_sig_wrong, v_publicKeyCompressed, v_compressedMode) == true) {
setverdict(fail);
}
if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig_wrong, v_publicKeyX, v_publicKeyY) == true) {
if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 8), v_sig_wrong, v_publicKeyX, v_publicKeyY) == true) {
setverdict(fail);
stop;
}
v_publicKeyX_wrong := v_publicKeyCompressed;
v_publicKeyX_wrong[0] := 'FF'O;
if (f_verifyWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 32), v_sig_wrong, v_publicKeyCompressed, v_compressedMode) == true) {
if (f_verifyWithEcdsaNistp256WithSha256(v_encMsg, int2oct(10, 8), v_sig_wrong, v_publicKeyCompressed, v_compressedMode) == true) {
setverdict(fail);
}
v_publicKeyX_wrong := v_publicKeyX;
v_publicKeyX_wrong[0] := 'FF'O;
if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX_wrong, v_publicKeyY) == true) {
if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyX_wrong, v_publicKeyY) == true) {
setverdict(fail);
stop;
}
v_publicKeyY_wrong := v_publicKeyY;
v_publicKeyY_wrong[0] := 'FF'O;
if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY_wrong) == true) {
if (f_verifyWithEcdsaNistp256WithSha256_1(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyX, v_publicKeyY_wrong) == true) {
setverdict(fail);
stop;
}
......@@ -394,7 +423,7 @@ module TestCodec_SecuredFuntions {
log("v_public_key Y= ", v_publicKeyY);
log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key);
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 8), v_private_key);
if (lengthof(v_sig) == 0) {
setverdict(fail);
stop;
......@@ -421,7 +450,7 @@ module TestCodec_SecuredFuntions {
log("v_public_key Y= ", v_publicKeyY);
log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
v_sig := f_signWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 48), v_private_key);
v_sig := f_signWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 8), v_private_key);
if (lengthof(v_sig) == 0) {
setverdict(fail);
stop;
......@@ -448,18 +477,18 @@ module TestCodec_SecuredFuntions {
log("v_public_key Y= ", v_publicKeyY);
log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key);
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 8), v_private_key);
if (lengthof(v_sig) == 0) {
setverdict(fail);
stop;
}
if (f_verifyWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
if (f_verifyWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
setverdict(fail);
} else {
setverdict(pass);
}
if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == false) {
if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyX, v_publicKeyY) == false) {
setverdict(fail);
} else {
setverdict(pass);
......@@ -487,31 +516,31 @@ module TestCodec_SecuredFuntions {
v_private_key_wrong := v_private_key;
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key);
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 8), v_private_key);
if (lengthof(v_sig) == 0) {
setverdict(fail);
stop;
}
if (f_verifyWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
if (f_verifyWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
setverdict(fail);
} else {
setverdict(pass);
}
if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == false) {
if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyX, v_publicKeyY) == false) {
setverdict(fail);
} else {
setverdict(pass);
}
v_private_key_wrong[2] := 'AA'O;
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key_wrong);
if (f_verifyWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyCompressed, v_compressedMode) == true) {
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 8), v_private_key_wrong);
if (f_verifyWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyCompressed, v_compressedMode) == true) {
setverdict(fail);
} else {
setverdict(pass);
}
if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == true) {
if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyX, v_publicKeyY) == true) {
setverdict(fail);
} else {
setverdict(pass);
......@@ -539,30 +568,30 @@ module TestCodec_SecuredFuntions {
log("v_public_key Y= ", v_publicKeyY);
log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 32), v_private_key);
if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == false) {
v_sig := f_signWithEcdsaBrainpoolp256WithSha256(v_encMsg, int2oct(10, 8), v_private_key);
if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyX, v_publicKeyY) == false) {
setverdict(fail);
}
if (f_verifyWithEcdsaBrainpoolp256WithSha256_1('0A0A0A0A'O, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY) == true) {
if (f_verifyWithEcdsaBrainpoolp256WithSha256_1('0A0A0A0A'O, int2oct(10, 8), v_sig, v_publicKeyX, v_publicKeyY) == true) {
setverdict(fail);
}
v_sig_wrong := v_sig;
v_sig_wrong[0] := 'FF'O;
if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig_wrong, v_publicKeyX, v_publicKeyY) == true) {
if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 8), v_sig_wrong, v_publicKeyX, v_publicKeyY) == true) {
setverdict(fail);
}
v_publicKeyX_wrong := v_publicKeyX;
v_publicKeyX_wrong[0] := 'FF'O;
if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX_wrong, v_publicKeyY) == true) {
if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyX_wrong, v_publicKeyY) == true) {
setverdict(fail);
}
v_publicKeyY_wrong := v_publicKeyY;
v_publicKeyY_wrong[0] := 'FF'O;
if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 32), v_sig, v_publicKeyX, v_publicKeyY_wrong) == true) {
if (f_verifyWithEcdsaBrainpoolp256WithSha256_1(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyX, v_publicKeyY_wrong) == true) {
setverdict(fail);
}
......@@ -587,18 +616,18 @@ module TestCodec_SecuredFuntions {
log("v_public_key Y= ", v_publicKeyY);
log("v_public_key compressed= ", v_publicKeyCompressed, v_compressedMode);
v_sig := f_signWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 48), v_private_key);
v_sig := f_signWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 8), v_private_key);
if (lengthof(v_sig) == 0) {
setverdict(fail);
stop;
}
if (f_verifyWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 48), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
if (f_verifyWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyCompressed, v_compressedMode) == false) {
setverdict(fail);
} else {
setverdict(pass);
}
if (f_verifyWithEcdsaBrainpoolp384WithSha384_1(v_encMsg, int2oct(10, 48), v_sig, v_publicKeyX, v_publicKeyY) == false) {
if (f_verifyWithEcdsaBrainpoolp384WithSha384_1(v_encMsg, int2oct(10, 8), v_sig, v_publicKeyX, v_publicKeyY) == false) {
setverdict(fail);
} else {
setverdict(pass);
......@@ -626,32 +655,32 @@ module TestCodec_SecuredFuntions {
v_private_key_wrong := v_private_key;
v_sig := f_signWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 48), v_private_key);
v_sig := f_signWithEcdsaBrainpoolp384WithSha384(v_encMsg, int2oct(10, 8), v_private_key);
if (lengthof(v_sig) == 0) {
setverdict(fail);
stop;