
com.theicenet.cryptography.keyagreement.KeyAgreementService Maven / Gradle / Ivy
/*
* Copyright 2019-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.theicenet.cryptography.keyagreement;
import java.security.PrivateKey;
import java.security.PublicKey;
/**
* A KeyAgreementService instance is a component which implements a cryptographic
* unauthenticated key-agreement protocol for two parties agree on a secret shared key
* in such a way that both influence the outcome.
*
* Instances of KeyAgreementService are valid to be used for unauthenticated
* securely exchanging cryptographic keys over a public channel.
*
* @see Key-agreement protocol
*
* @apiNote Any implementation of this interface must be unconditionally thread-safe.
*
* @author Juan Fidalgo
* @since 1.0.0
*/
public interface KeyAgreementService {
/**
* Generates a common, repeatable and deterministic secret shared key which is influenced
* by the privateKey and the publicKey.
*
* The generation of the shared secret involves two parties (Bod and Alice) and their key pairs.
*
* @param privateKey Bob's (or Alice) private key (format PCKS #8) to use to generate the
* secret shared key
* @param publicKey Alice's (or Bob) public key (format X.509) to use to generate the
* secret shared key
* @return generated common secret shared key which satisfies that,
* generateSecretKey(bobPrivateKey, alicePublicKey) is equals to
* generateSecretKey(alicePrivateKey, bobPublicKey)
*
* @see X.509
* @see PKCS #8
*/
byte[] generateSecretKey(PrivateKey privateKey, PublicKey publicKey);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy