goto bail_out;
}
+ /* Set up the encryption context and send the session data to the SD */
+ if (has_file_data && jcr->pki_encrypt) {
+ /* Send our header */
+ Dmsg2(100, "Send hdr fi=%ld stream=%d\n", jcr->JobFiles, STREAM_ENCRYPTED_SESSION_DATA);
+ bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, STREAM_ENCRYPTED_SESSION_DATA);
+
+ /* Grow the bsock buffer to fit our message if necessary */
+ if (sizeof_pool_memory(sd->msg) < jcr->pki_session_encoded_size) {
+ sd->msg = realloc_pool_memory(sd->msg, jcr->pki_session_encoded_size);
+ }
+
+ /* Copy our message over and send it */
+ memcpy(sd->msg, jcr->pki_session_encoded, jcr->pki_session_encoded_size);
+ sd->msglen = jcr->pki_session_encoded_size;
+ jcr->JobBytes += sd->msglen;
+
+ Dmsg1(100, "Send data len=%d\n", sd->msglen);
+ bnet_send(sd);
+ bnet_sig(sd, BNET_EOD);
+ }
+
/*
* Open any file with data that we intend to save, then save it.
*
tid = NULL;
}
- /* Set up the encryption context, send the session data to the SD */
- if (jcr->pki_encrypt) {
- /* Send our header */
- Dmsg2(100, "Send hdr fi=%ld stream=%d\n", jcr->JobFiles, STREAM_ENCRYPTED_SESSION_DATA);
- bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, STREAM_ENCRYPTED_SESSION_DATA);
-
- /* Grow the bsock buffer to fit our message if necessary */
- if (sizeof_pool_memory(sd->msg) < jcr->pki_session_encoded_size) {
- sd->msg = realloc_pool_memory(sd->msg, jcr->pki_session_encoded_size);
- }
-
- /* Copy our message over and send it */
- memcpy(sd->msg, jcr->pki_session_encoded, jcr->pki_session_encoded_size);
- sd->msglen = jcr->pki_session_encoded_size;
- jcr->JobBytes += sd->msglen;
-
- Dmsg1(100, "Send data len=%d\n", sd->msglen);
- bnet_send(sd);
- bnet_sig(sd, BNET_EOD);
- }
-
stat = send_data(jcr, data_stream, ff_pkt, digest, signing_digest);
if (ff_pkt->flags & FO_CHKCHANGES) {
continue;
}
- /* Set up a decryption context */
- if ((cipher_ctx.cipher = crypto_cipher_new(cs, false, &cipher_ctx.block_size)) == NULL) {
- Jmsg1(jcr, M_ERROR, 0, _("Failed to initialize decryption context for %s\n"), jcr->last_fname);
- crypto_session_free(cs);
- cs = NULL;
- extract = false;
- bclose(&bfd);
- continue;
- }
-
break;
case STREAM_FILE_DATA:
if (stream == STREAM_ENCRYPTED_FILE_DATA
|| stream == STREAM_ENCRYPTED_FILE_GZIP_DATA
|| stream == STREAM_ENCRYPTED_WIN32_DATA
- || stream == STREAM_ENCRYPTED_WIN32_GZIP_DATA) {
+ || stream == STREAM_ENCRYPTED_WIN32_GZIP_DATA) {
+ /* Set up a decryption context */
if (!cipher_ctx.cipher) {
- Jmsg1(jcr, M_ERROR, 0, _("Missing encryption session data stream for %s\n"), jcr->last_fname);
- extract = false;
- bclose(&bfd);
- continue;
+ if (!cs) {
+ Jmsg1(jcr, M_ERROR, 0, _("Missing encryption session data stream for %s\n"), jcr->last_fname);
+ extract = false;
+ bclose(&bfd);
+ continue;
+ }
+
+ if ((cipher_ctx.cipher = crypto_cipher_new(cs, false, &cipher_ctx.block_size)) == NULL) {
+ Jmsg1(jcr, M_ERROR, 0, _("Failed to initialize decryption context for %s\n"), jcr->last_fname);
+ crypto_session_free(cs);
+ cs = NULL;
+ extract = false;
+ bclose(&bfd);
+ continue;
+ }
}
flags |= FO_ENCRYPT;
}