michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: package org.mozilla.gecko.browserid; michael@0: michael@0: import java.security.GeneralSecurityException; michael@0: michael@0: import org.mozilla.gecko.sync.ExtendedJSONObject; michael@0: michael@0: public interface SigningPrivateKey { michael@0: /** michael@0: * Return the JSON Web Token "alg" header corresponding to this private key. michael@0: *

michael@0: * The header is used when formatting web tokens, and generally denotes the michael@0: * algorithm and an ad-hoc encoding of the key size. michael@0: * michael@0: * @return header. michael@0: */ michael@0: public String getAlgorithm(); michael@0: michael@0: /** michael@0: * Generate a JSON representation of a private key. michael@0: *

michael@0: * This should only be used for debugging. No private keys should go over michael@0: * the wire at any time. michael@0: * michael@0: * @param privateKey michael@0: * to represent. michael@0: * @return JSON representation. michael@0: */ michael@0: public ExtendedJSONObject toJSONObject(); michael@0: michael@0: /** michael@0: * Sign a message. michael@0: * @param message to sign. michael@0: * @return signature. michael@0: * @throws GeneralSecurityException michael@0: */ michael@0: public byte[] signMessage(byte[] message) throws GeneralSecurityException; michael@0: }