| 13 | time_t k_timeTestNow = 1555374048; |
| 14 | |
| 15 | void GenerateCert( CMsgSteamDatagramCertificateSigned &msgOut, const char *certData, const CECSigningPrivateKey &keyCAPrivateKey, uint64 nCAKeyID ) |
| 16 | { |
| 17 | msgOut.Clear(); |
| 18 | |
| 19 | // Generate a dummy cert with the requested fields and give it a keypair |
| 20 | { |
| 21 | CMsgSteamDatagramCertificate msgCert; |
| 22 | DbgVerify( google::protobuf::TextFormat::ParseFromString( std::string( certData ), &msgCert ) ); |
| 23 | |
| 24 | msgCert.set_time_expiry( k_timeTestNow + 3600*8 ); |
| 25 | |
| 26 | CECSigningPrivateKey tempIdentityPrivateKey; |
| 27 | CECSigningPublicKey tempIdentityPublicKey; |
| 28 | CCrypto::GenerateSigningKeyPair( &tempIdentityPublicKey, &tempIdentityPrivateKey ); |
| 29 | DbgVerify( tempIdentityPublicKey.GetRawDataAsStdString( msgCert.mutable_key_data() ) ); |
| 30 | msgCert.set_key_type( CMsgSteamDatagramCertificate_EKeyType_ED25519 ); |
| 31 | |
| 32 | DbgVerify( msgCert.SerializeToString( msgOut.mutable_cert() ) ); |
| 33 | } |
| 34 | |
| 35 | // Sign it |
| 36 | CryptoSignature_t sig; |
| 37 | keyCAPrivateKey.GenerateSignature( msgOut.cert().c_str(), msgOut.cert().length(), &sig ); |
| 38 | msgOut.set_ca_key_id( nCAKeyID ); |
| 39 | msgOut.set_ca_signature( &sig, sizeof(sig) ); |
| 40 | } |
| 41 | |
| 42 | int main() |
| 43 | { |
no test coverage detected