unser_bytes(Id, BLKHDR_ID_LENGTH);
ASSERT(unser_length(block->buf) == BLKHDR1_LENGTH);
Id[BLKHDR_ID_LENGTH] = 0;
- block->CheckSum64 = CheckSumLo; // only for BB01 & BB02
+ block->CheckSum64 = CheckSumLo; /* only for BB01 & BB02 */
+ block->blkh_options = BLKHOPT_NONE; /* only in BB03 */
if (Id[3] == '1') {
bhl = BLKHDR1_LENGTH;
block->BlockVer = 1;
}
} else if (Id[3] == '3') {
bhl = BLKHDR3_LENGTH;
- uint32_t blkh_options = CheckSumLo; /* in BB03 blkh_options is stored at the checksum location */
+ block->blkh_options = CheckSumLo; /* in BB03 blkh_options is stored at the checksum location */
unser_uint32(block->VolSessionId);
unser_uint32(block->VolSessionTime);
-
/* decrypt the block before to calculate the checksum */
- if ((blkh_options & BLKHOPT_ENCRYPT_BLOCK) && block->dev->crypto_device_ctx)
+ if ((block->blkh_options & BLKHOPT_ENCRYPT_BLOCK) && block->dev->crypto_device_ctx)
{
block_cipher_init_iv_header(block->dev->crypto_device_ctx, BlockNumber, block->VolSessionId, block->VolSessionTime);
block_cipher_decrypt(block->dev->crypto_device_ctx, block_len-bhl, block->buf+bhl, block->buf_enc);
}
/* don't use encryption if volume encryption is not enable or we are reading
* (aka not recycling) a BB02 volume */
- if (device->volume_encryption == ET_NONE || (op != op_label && VolHdr.BlockVer <= 2)) {
+ if (device->volume_encryption == ET_NONE || (op != op_label && !(VolHdr.blkh_options & BLKHOPT_ENCRYPT_VOL))) {
return ok;
}
JCR *jcr = dcr->jcr;
dev->VolHdr.LabelType = rec->FileIndex;
dev->VolHdr.LabelSize = rec->data_len;
dev->VolHdr.BlockVer = rec->BlockVer;
+ dev->VolHdr.blkh_options = rec->blkh_options;
/* Unserialize the record into the Volume Header */
Dmsg2(100, "reclen=%d recdata=%s", rec->data_len, rec->data);
uint32_t extra_bytes; /* the extra size that must be accounted in VolABytes */
uint32_t state_bits; /* state bits */
uint32_t RecNum; /* Record number in the block */
- int BlockVer; /* 1, 2 or .. from BB01, BB02, ... */
+ int BlockVer; /* from the block header: 1,2,3 from BB?? */
+ uint32_t blkh_options; /* from the block header: about block encryption */
uint32_t BlockNumber; /* Block number for this record (used in read_records()) */
bool invalid; /* The record may be invalid if it was merged with a previous record */
rec_state wstate; /* state of write_record_to_block */
uint32_t VerNum; /* Label version number */
int BlockVer; /* 1, 2 or .. from BB01, BB02 from the FIRST block */
+ uint32_t blkh_options; /* the block options bits from the FIRST block */
/* VerNum <= 10 */
float64_t label_date; /* Date tape labeled */
float64_t label_time; /* Time tape labeled */
uint64_t MaxPartSize; /* Maximum Part Size */
/* For Volume encryption */
+ bool is_vol_encrypted;
uint32_t EncCypherKeySize;
uint32_t MasterKeyIdSize;
unsigned char EncCypherKey[MAX_BLOCK_CIPHER_KEY_LEN]; /* The encryption key
rec->Addr = rec->StartAddr = dcr->block->BlockAddr;
}
rec->BlockVer = dcr->block->BlockVer; /* needed for unser_volume_label() */
+ rec->blkh_options = dcr->block->blkh_options; /* needed for unser_volume_label() */
/* We read the next record */
dcr->block->RecNum++;