com.adobe.granite.crypto.spi.KeyProvider Maven / Gradle / Ivy
/*************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2016 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
package com.adobe.granite.crypto.spi;
import com.adobe.granite.crypto.CryptoException;
import org.osgi.annotation.versioning.ConsumerType;
/**
* The KeyProvider
provides a simple API to obtain cryptographic keys stored in
* a storage system.The underlying storage system is indicated by the getLabel()
method.
* Currently supported algorithm are defined in {@link com.adobe.granite.crypto.spi.Algorithms}
*/
@ConsumerType
public interface KeyProvider {
/**
* The service registration property indicating which storage support to use for
* this bundle instance ("granite.crypto.storage").
*
*/
public static final String STORAGE_SUPPORT = "granite.crypto.storage";
/**
* Returns a short description of the support bundle to indicate what
* kind of storage is going to be used.
*
* @return a short human readable description
*/
String getStorageType();
/**
* Obtain the current cryptographic key present in the storage.
* The storage used for the key returned must be protected by additional means such as
* access control against abuse of the key. The key is generated once at startup via
* the {@link com.adobe.granite.crypto.spi.KeyGenerator} and stays the same
* for the lifetime of the service (unless is physically erased in the storage
* system)
*
*
* @param algorithm the standard string name of the algorithm.
* Currently supported algorithm are defined
* in {@link com.adobe.granite.crypto.spi.Algorithms}
* @return the related stored key
* @throws CryptoException If any problem occurs while obtaining the key
*/
public byte[] obtainKey(Algorithms algorithm) throws CryptoException;
}