/// <summary> /// Revokes a global <see cref="VirgilCard"/> from Virgil Security services. /// </summary> /// <param name="card">The Card to be revoked.</param> /// <param name="key">The Key associated with the revoking Card.</param> /// <param name="identityToken">The identity token.</param> public async Task RevokeGlobalAsync(VirgilCard card, VirgilKey key, IdentityValidationToken identityToken) { var revokeRequest = new RevokeGlobalCardRequest(card.Id, RevocationReason.Unspecified, identityToken.Value); var fingerprint = this.context.Crypto.CalculateFingerprint(revokeRequest.Snapshot); var signature = key.Sign(fingerprint.GetValue()); revokeRequest.AppendSignature(card.Id, signature.GetBytes()); await this.context.Client.RevokeGlobalCardAsync(revokeRequest); }
private CardModel BuildCardModel ( string identity, string identityType, Dictionary <string, string> customFields, CardScope scope, VirgilKey ownerKey ) { var cardSnapshotModel = new PublishCardSnapshotModel { Identity = identity, IdentityType = identityType, Info = new CardInfoModel { DeviceName = this.context.DeviceManager.GetDeviceName(), Device = this.context.DeviceManager.GetSystemName() }, PublicKeyData = ownerKey.ExportPublicKey().GetBytes(), Scope = scope, Data = customFields }; var snapshot = new Snapshotter().Capture(cardSnapshotModel); var snapshotFingerprint = this.context.Crypto.CalculateFingerprint(snapshot); var cardId = snapshotFingerprint.ToHEX(); var selfSignature = ownerKey.Sign(VirgilBuffer.From(snapshotFingerprint.GetValue())); var signatures = new Dictionary <string, byte[]> { [cardId] = selfSignature.GetBytes() }; var cardModel = new CardModel(cardSnapshotModel) { Id = cardId, Snapshot = snapshot, Meta = new CardMetaModel { Signatures = signatures } }; return(cardModel); }
/// <summary> /// Signs a byte array data using current <see cref="VirgilKey"/>. /// </summary> /// <param name="virgilKey">The <see cref="VirgilKey"/> used to sign the <paramref name="data"/></param> /// <param name="data">The plaintext to be signed.</param> /// <returns>A new <see cref="VirgilBuffer"/> instance with generated signature.</returns> public static VirgilBuffer Sign(this VirgilKey virgilKey, byte[] data) { return(virgilKey.Sign(VirgilBuffer.From(data))); }
/// <summary> /// Signs a plaintext using current <see cref="VirgilKey"/>. /// </summary> /// <param name="virgilKey">The <see cref="VirgilKey"/> used to sign the <paramref name="plaintext"/></param> /// <param name="plaintext">The plaintext to be signed.</param> /// <returns>A new <see cref="VirgilBuffer"/> instance with generated signature.</returns> public static VirgilBuffer Sign(this VirgilKey virgilKey, string plaintext) { return(virgilKey.Sign(VirgilBuffer.From(plaintext))); }