//-----------------------------------------------------------------------
//
// Copyright (c) Outercurve Foundation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Messaging.Bindings {
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using DotNetOpenAuth.Messaging;
using Validation;
///
/// A persistent store for rotating symmetric cryptographic keys.
///
///
/// Implementations should persist it in such a way that the keys are shared across all servers
/// on a web farm, where applicable.
/// The store should consider protecting the persistent store against theft resulting in the loss
/// of the confidentiality of the keys. One possible mitigation is to asymmetrically encrypt
/// each key using a certificate installed in the server's certificate store.
///
public interface ICryptoKeyStore {
///
/// Gets the key in a given bucket and handle.
///
/// The bucket name. Case sensitive.
/// The key handle. Case sensitive.
/// The cryptographic key, or null if no matching key was found.
CryptoKey GetKey(string bucket, string handle);
///
/// Gets a sequence of existing keys within a given bucket.
///
/// The bucket name. Case sensitive.
/// A sequence of handles and keys, ordered by descending .
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "Important for scalability")]
IEnumerable> GetKeys(string bucket);
///
/// Stores a cryptographic key.
///
/// The name of the bucket to store the key in. Case sensitive.
/// The handle to the key, unique within the bucket. Case sensitive.
/// The key to store.
/// Thrown in the event of a conflict with an existing key in the same bucket and with the same handle.
void StoreKey(string bucket, string handle, CryptoKey key);
///
/// Removes the key.
///
/// The bucket name. Case sensitive.
/// The key handle. Case sensitive.
void RemoveKey(string bucket, string handle);
}
}