1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17/** 18 * @author Boris V. Kuznetsov 19 */ 20 21package org.apache.harmony.security.tests.support; 22 23import java.security.InvalidKeyException; 24import java.security.InvalidParameterException; 25import java.security.PrivateKey; 26import java.security.PublicKey; 27import java.security.SignatureException; 28import java.security.SignatureSpi; 29 30/** 31 * Tests implementation of Signature 32 */ 33public class MySignature2 extends SignatureSpi { 34 35 public static boolean runEngineInitVerify = false; 36 public static boolean runEngineInitSign = false; 37 public static boolean runEngineUpdate1 = false; 38 public static boolean runEngineUpdate2 = false; 39 public static boolean runEngineSign = false; 40 public static boolean runEngineVerify = false; 41 public static boolean runEngineSetParameter = false; 42 public static boolean runEngineGetParameter = false; 43 44 protected void engineInitVerify(PublicKey publicKey) 45 throws InvalidKeyException { 46 runEngineInitVerify = true; 47 } 48 49 protected void engineInitSign(PrivateKey privateKey) 50 throws InvalidKeyException { 51 runEngineInitSign = true; 52 } 53 54 protected void engineUpdate(byte b) throws SignatureException { 55 runEngineUpdate1 = true; 56 } 57 58 protected void engineUpdate(byte[] b, int off, int len) 59 throws SignatureException { 60 runEngineUpdate2 = true; 61 } 62 63 protected byte[] engineSign() throws SignatureException { 64 runEngineSign = true; 65 return null; 66 } 67 68 protected boolean engineVerify(byte[] sigBytes) throws SignatureException { 69 runEngineVerify = true; 70 return false; 71 } 72 73 protected void engineSetParameter(String param, Object value) 74 throws InvalidParameterException { 75 runEngineSetParameter = true; 76 } 77 78 protected Object engineGetParameter(String param) 79 throws InvalidParameterException { 80 runEngineGetParameter = true; 81 return null; 82 } 83} 84