Beispiel #1
0
        /// <summary>
        /// Use this method to encrypt the user secrets (Storage Account Access Key, Volume Container Encryption Key etc.)
        /// </summary>
        /// <param name="deviceName">
        /// The resource name.
        /// </param>
        /// <param name="resourceGroupName">
        /// The resource group name.
        /// </param>
        /// <param name="plainTextSecret">
        /// The plain text secret.
        /// </param>
        /// <returns>
        /// The <see cref="AsymmetricEncryptedSecret"/>.
        /// </returns>
        /// <exception cref="ValidationException">
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// </exception>
        public static AsymmetricEncryptedSecret GetAsymmetricEncryptedSecretFromCIK(
            this IDevicesOperations operations,
            string deviceName,
            string resourceGroupName,
            string plainTextSecret,
            string channelIntegrationKey)
        {
            if (string.IsNullOrWhiteSpace(plainTextSecret))
            {
                throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "plainTextSecret");
            }

            if (string.IsNullOrWhiteSpace(resourceGroupName))
            {
                throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName");
            }

            if (string.IsNullOrWhiteSpace(deviceName))
            {
                throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceName");
            }

            DataBoxEdgeDeviceExtendedInfo extendedInfo = operations.GetExtendedInformation(deviceName, resourceGroupName);
            string encryptionKey           = extendedInfo.EncryptionKey;
            string encryptionKeyThumbprint = extendedInfo.EncryptionKeyThumbprint;

            string ChannelEncryptionKey = CryptoUtilities.DecryptStringAES(encryptionKey, channelIntegrationKey);

            var secret = new AsymmetricEncryptedSecret()
            {
                EncryptionAlgorithm      = EncryptionAlgorithm.AES256,
                EncryptionCertThumbprint = encryptionKeyThumbprint,
                Value = CryptoUtilities.EncryptStringRsaPkcs1v15(plainTextSecret, ChannelEncryptionKey)
            };

            return(secret);
        }
Beispiel #2
0
 /// <summary>
 /// Creates or updates the additional information of a the data box
 /// edge/gateway device.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='deviceName'>
 /// The device name.
 /// </param>
 /// <param name='parameters'>
 /// The additional information.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The resource group name.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <DataBoxEdgeDeviceExtendedInfo> CreateOrUpdateExtendedInfoAsync(this IDevicesOperations operations, string deviceName, DataBoxEdgeDeviceExtendedInfo parameters, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateExtendedInfoWithHttpMessagesAsync(deviceName, parameters, resourceGroupName, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Creates or updates the additional information of a the data box
 /// edge/gateway device.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='deviceName'>
 /// The device name.
 /// </param>
 /// <param name='parameters'>
 /// The additional information.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The resource group name.
 /// </param>
 public static DataBoxEdgeDeviceExtendedInfo CreateOrUpdateExtendedInfo(this IDevicesOperations operations, string deviceName, DataBoxEdgeDeviceExtendedInfo parameters, string resourceGroupName)
 {
     return(operations.CreateOrUpdateExtendedInfoAsync(deviceName, parameters, resourceGroupName).GetAwaiter().GetResult());
 }