public async Task RunAsync() { try { #if DEBUG ECDsa = System.Security.Cryptography.ECDsaCng.Create(ECCurve.NamedCurves.nistP256); #else if (KeyVaultKey == null) { KeyVaultKey = await KeyVault.GetKeyAsync(TekExportKeyVaultKeyUrl); SigInfo.VerificationKeyId = KeyVaultKey.Key.Kid; SigInfo.VerificationKeyVersion = KeyVaultKey.KeyIdentifier.Version; ECDsa = KeyVaultKey.Key.ToECDsa(true); } #endif var items = await TekRepository.GetNextAsync(); await CreateAsync(items); } catch (Exception ex) { Logger.LogError(ex, $"Error on {nameof(TemporaryExposureKeyService)}"); throw; } }
internal PSKeyVaultKey(Microsoft.Azure.KeyVault.Models.KeyBundle keyBundle, VaultUriHelper vaultUriHelper) { if (keyBundle == null) { throw new ArgumentNullException("keyBundle"); } if (keyBundle.Key == null || keyBundle.Attributes == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidKeyBundle); } SetObjectIdentifier(vaultUriHelper, keyBundle.KeyIdentifier); Key = keyBundle.Key; Attributes = new PSKeyVaultKeyAttributes( keyBundle.Attributes.Enabled, keyBundle.Attributes.Expires, keyBundle.Attributes.NotBefore, keyBundle.Key.Kty, keyBundle.Key.KeyOps.ToArray(), keyBundle.Attributes.Created, keyBundle.Attributes.Updated, keyBundle.Attributes.RecoveryLevel, keyBundle.Tags); Enabled = keyBundle.Attributes.Enabled; Expires = keyBundle.Attributes.Expires; NotBefore = keyBundle.Attributes.NotBefore; Created = keyBundle.Attributes.Created; Updated = keyBundle.Attributes.Updated; RecoveryLevel = keyBundle.Attributes.RecoveryLevel; Tags = (keyBundle.Tags == null) ? null : keyBundle.Tags.ConvertToHashtable(); }
public async Task RunAsync() { try { #if !DEBUG KeyVaultKey = await KeyVault.GetKeyAsync(TekExportKeyVaultKeyUrl); SigInfo.VerificationKeyId = KeyVaultKey.Key.Kid; SigInfo.VerificationKeyVersion = KeyVaultKey.KeyIdentifier.Version; #endif var items = await TekRepository.GetNextAsync(); foreach (var kv in items.GroupBy(_ => new { _.RollingStartUnixTimeSeconds, _.RollingPeriodSeconds })) { await CreateAsync((ulong)kv.Key.RollingStartUnixTimeSeconds, (ulong)(kv.Key.RollingStartUnixTimeSeconds + kv.Key.RollingPeriodSeconds), kv.ToArray()); } } catch (Exception ex) { Logger.LogError(ex, $"Error on {nameof(TemporaryExposureKeyService)}"); throw; } }
private async Task InitializeAsync() { Logger.LogInformation($"start {nameof(InitializeAsync)}"); if (KeyVaultKey == null) { KeyVaultKey = await KeyVault.GetKeyAsync(TekExportKeyVaultKeyUrl); } }
private async Task InitializeAsync() { if (KeyVaultKey == null) { KeyVaultKey = await KeyVault.GetKeyAsync(TekExportKeyVaultKeyUrl); PublicKey = KeyVaultKey.Key.ToECDsa().ExportSubjectPublicKeyInfo(); } }
static void importKeyToVault(JwtRsaKey key, string token, string vaultUrl) { var client = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(async(authority, resource, scope) => await Task.FromResult(token))); var keyBnd = new Microsoft.Azure.KeyVault.Models.KeyBundle(); keyBnd.Key = new Microsoft.Azure.KeyVault.WebKey.JsonWebKey { Kty = key.kty, Kid = key.kid, E = Encoding.UTF8.GetBytes(key.e), P = Encoding.UTF8.GetBytes(key.p), Q = Encoding.UTF8.GetBytes(key.q), QI = Encoding.UTF8.GetBytes(key.qi), DP = Encoding.UTF8.GetBytes(key.dp), DQ = Encoding.UTF8.GetBytes(key.dq) }; var result = client.ImportKeyAsync(vaultUrl, key.kid, keyBnd).Result; }