// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.AspNet.DataProtection
{
///
/// An interface that can provide data protection services where payloads have
/// a finite lifetime.
///
///
/// It is intended that payload lifetimes be somewhat short. Payloads protected
/// via this mechanism are not intended for long-term persistence (e.g., longer
/// than a few weeks).
///
public interface ITimeLimitedDataProtector : IDataProtector
{
///
/// Creates an given a purpose.
///
///
/// The purpose to be assigned to the newly-created .
///
/// An tied to the provided purpose.
///
/// The parameter must be unique for the intended use case; two
/// different instances created with two different
/// values will not be able to decipher each other's payloads. The parameter
/// value is not intended to be kept secret.
///
new ITimeLimitedDataProtector CreateProtector(string purpose);
///
/// Cryptographically protects a piece of plaintext data, expiring the data at
/// the chosen time.
///
/// The plaintext data to protect.
/// The time when this payload should expire.
/// The protected form of the plaintext data.
byte[] Protect(byte[] plaintext, DateTimeOffset expiration);
///
/// Cryptographically unprotects a piece of protected data.
///
/// The protected data to unprotect.
/// An 'out' parameter which upon a successful unprotect
/// operation receives the expiration date of the payload.
/// The plaintext form of the protected data.
///
/// Thrown if is invalid, malformed, or expired.
///
byte[] Unprotect(byte[] protectedData, out DateTimeOffset expiration);
}
}