001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.geronimo.util.crypto;
019
020 import java.math.BigInteger;
021
022 /**
023 * interface for classes implementing algorithms modeled similar to the Digital Signature Alorithm.
024 */
025 public interface DSA
026 {
027 /**
028 * initialise the signer for signature generation or signature
029 * verification.
030 *
031 * @param forSigning true if we are generating a signature, false
032 * otherwise.
033 * @param param key parameters for signature generation.
034 */
035 public void init(boolean forSigning, CipherParameters param);
036
037 /**
038 * sign the passed in message (usually the output of a hash function).
039 *
040 * @param message the message to be signed.
041 * @return two big integers representing the r and s values respectively.
042 */
043 public BigInteger[] generateSignature(byte[] message);
044
045 /**
046 * verify the message message against the signature values r and s.
047 *
048 * @param message the message that was supposed to have been signed.
049 * @param r the r signature value.
050 * @param s the s signature value.
051 */
052 public boolean verifySignature(byte[] message, BigInteger r, BigInteger s);
053 }