MCPcopy Create free account
hub / github.com/ValveSoftware/GameNetworkingSockets / GenerateCert

Function GenerateCert

tests/test_pki.cpp:15–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13time_t k_timeTestNow = 1555374048;
14
15void 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
42int main()
43{

Callers 1

mainFunction · 0.85

Calls 4

GetRawDataAsStdStringMethod · 0.80
ClearMethod · 0.45
GenerateSignatureMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected