MCPcopy Create free account
hub / github.com/apache/qpid-proton / ssl_encrypt

Function ssl_encrypt

c/src/ssl/schannel.cpp:969–1001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

967}
968
969static void ssl_encrypt(pn_transport_t *transport, char *app_data, size_t count)
970{
971 pni_ssl_t *ssl = transport->ssl;
972
973 // Get SChannel to encrypt exactly one Record.
974 SecBuffer buffs[4];
975 buffs[0].cbBuffer = ssl->sc_sizes.cbHeader;
976 buffs[0].BufferType = SECBUFFER_STREAM_HEADER;
977 buffs[0].pvBuffer = ssl->sc_outbuf;
978 buffs[1].cbBuffer = count;
979 buffs[1].BufferType = SECBUFFER_DATA;
980 buffs[1].pvBuffer = app_data;
981 buffs[2].cbBuffer = ssl->sc_sizes.cbTrailer;
982 buffs[2].BufferType = SECBUFFER_STREAM_TRAILER;
983 buffs[2].pvBuffer = &app_data[count];
984 buffs[3].cbBuffer = 0;
985 buffs[3].BufferType = SECBUFFER_EMPTY;
986 buffs[3].pvBuffer = 0;
987 SecBufferDesc buff_desc;
988 buff_desc.ulVersion = SECBUFFER_VERSION;
989 buff_desc.cBuffers = 4;
990 buff_desc.pBuffers = buffs;
991 SECURITY_STATUS status = EncryptMessage(&ssl->ctxt_handle, 0, &buff_desc, 0);
992 assert(status == SEC_E_OK);
993
994 // EncryptMessage encrypts the data in place. The header and trailer
995 // areas were reserved previously and must now be included in the updated
996 // count of bytes to write to the peer.
997 ssl->sc_out_count = buffs[0].cbBuffer + buffs[1].cbBuffer + buffs[2].cbBuffer;
998 ssl->network_outp = ssl->sc_outbuf;
999 ssl->network_out_pending = ssl->sc_out_count;
1000 ssl_log(transport, PN_LEVEL_TRACE, "ssl_encrypt %zu network bytes", ssl->network_out_pending);
1001}
1002
1003// Returns true if decryption succeeded (even for empty content)
1004static bool ssl_decrypt(pn_transport_t *transport)

Callers 1

process_output_sslFunction · 0.85

Calls 1

ssl_logFunction · 0.70

Tested by

no test coverage detected