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

Method GetAsOpenSSHAuthorizedKeys

src/common/keypair.cpp:605–650  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

603//-----------------------------------------------------------------------------
604
605bool CECSigningPublicKey::GetAsOpenSSHAuthorizedKeys( char *pchData, uint32 cubData, uint32 *pcubData, const char *pszComment ) const
606{
607 if ( !IsValid() )
608 return false;
609
610 int cchComment = pszComment ? V_strlen( pszComment ) : 0;
611
612 uint8 publicKey[ 32 ];
613 VerifyFatal( GetRawData( publicKey ) == 32 );
614
615 CUtlBuffer bufBinary;
616 OpenSSHBinaryEd25519WritePublic( bufBinary, publicKey );
617
618 static const char pchPrefix[] = "ssh-ed25519 ";
619
620 uint32_t uRequiredBytes =
621 V_strlen( pchPrefix )
622 + CCrypto::Base64EncodeMaxOutput( bufBinary.TellPut(), "" )
623 + ( cchComment > 0 ? 1 : 0 ) // space
624 + cchComment
625 + 1; // '\0'
626 if ( pcubData )
627 *pcubData = uRequiredBytes;
628
629 if ( pchData )
630 {
631 if ( cubData < uRequiredBytes )
632 return false;
633
634 V_strncpy( pchData, pchPrefix, cubData );
635 uint32_t uRemainingBytes = cubData - V_strlen( pchData );
636
637 if ( !CCrypto::Base64Encode( (const uint8 *)bufBinary.Base(), bufBinary.TellPut(), pchData + V_strlen( pchData ), &uRemainingBytes, "" ) )
638 return false;
639
640 if ( pszComment )
641 {
642 V_strncat( pchData, " ", cubData );
643 V_strncat( pchData, pszComment, cubData );
644 }
645 if ( pcubData )
646 *pcubData = V_strlen( pchData ) + 1;
647 }
648
649 return true;
650}
651
652bool CECSigningPublicKey::LoadFromAndWipeBuffer( void *pBuffer, size_t cBytes )
653{

Callers 3

GenKeyPairFunction · 0.80
TestOpenSSHEd25519Function · 0.80

Calls 6

V_strlenFunction · 0.85
V_strncpyFunction · 0.85
V_strncatFunction · 0.85
TellPutMethod · 0.80
BaseMethod · 0.45

Tested by 1

TestOpenSSHEd25519Function · 0.64