本文整理汇总了C++中DEVICE::set_crypto_enabled方法的典型用法代码示例。如果您正苦于以下问题:C++ DEVICE::set_crypto_enabled方法的具体用法?C++ DEVICE::set_crypto_enabled怎么用?C++ DEVICE::set_crypto_enabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DEVICE
的用法示例。
在下文中一共展示了DEVICE::set_crypto_enabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_set_scsi_encryption_key
static bRC do_set_scsi_encryption_key(void *value)
{
DCR *dcr;
DEVICE *dev;
DEVRES *device;
DIRRES *director;
char StoredVolEncrKey[MAX_NAME_LENGTH];
char VolEncrKey[MAX_NAME_LENGTH];
/*
* Unpack the arguments passed in.
*/
dcr = (DCR *)value;
if (!dcr) {
return bRC_Error;
}
dev = dcr->dev;
if (!dev) {
return bRC_Error;
}
device = dev->device;
if (!device) {
return bRC_Error;
}
*StoredVolEncrKey = '\0';
if (!get_volume_encryption_key(dcr, StoredVolEncrKey)) {
return bRC_Error;
}
/*
* See if a volume encryption key is available.
*/
if (!*StoredVolEncrKey) {
Dmsg0(dbglvl, "scsicrypto-sd: No encryption key to load on device\n");
return bRC_OK;
}
/*
* See if device supports hardware encryption.
*/
if (!device->drive_crypto_enabled) {
Dmsg0(dbglvl, "scsicrypto-sd: Trying to load encryption key on drive without support\n");
Emsg0(M_ERROR, 0,
_("scsicrypto-sd: Trying to load encryption key on drive without support\n"));
return bRC_Error;
}
/*
* The key passed from the director to the storage daemon is always base64 encoded.
*/
base64_to_bin(VolEncrKey, sizeof(VolEncrKey), StoredVolEncrKey, strlen(StoredVolEncrKey));
/*
* See if we have an key encryption key in the config then the passed key
* has been wrapped using RFC3394 key wrapping. We first copy the current
* wrapped key into a temporary variable for unwrapping.
*/
if (dcr->jcr && dcr->jcr->director) {
director = dcr->jcr->director;
if (director->keyencrkey) {
char WrappedVolEncrKey[MAX_NAME_LENGTH];
memcpy(WrappedVolEncrKey, VolEncrKey, MAX_NAME_LENGTH);
memset(VolEncrKey, 0, MAX_NAME_LENGTH);
if (aes_unwrap((unsigned char *)director->keyencrkey,
DEFAULT_PASSPHRASE_LENGTH / 8,
(unsigned char *)WrappedVolEncrKey,
(unsigned char *)VolEncrKey) != 0) {
Dmsg1(dbglvl,
"scsicrypto-sd: Failed to unwrap encryption key using %s\n", director->keyencrkey);
Emsg0(M_ERROR, 0,
_("scsicrypto-sd: Failed to unwrap encryption key, probably wrong KeyEncryptionKey in config\n"));
return bRC_Error;
}
}
}
Dmsg1(dbglvl, "scsicrypto-sd: Loading new crypto key %s\n", VolEncrKey);
P(crypto_operation_mutex);
if (set_scsi_encryption_key(dev->fd(), dev->dev_name, VolEncrKey)) {
dev->set_crypto_enabled();
V(crypto_operation_mutex);
return bRC_OK;
} else {
V(crypto_operation_mutex);
return bRC_Error;
}
}