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 package org.apache.harmony.security.provider.crypto; 19 20 import java.security.AccessController; 21 import java.security.Provider; 22 23 /** 24 * Implementation of Provider for SecureRandom, MessageDigest and Signature 25 * using a Secure Hash Algorithm, SHA-1; 26 * see SECURE HASH STANDARD, FIPS PUB 180-1 (http://www.itl.nist.gov/fipspubs/fip180-1.htm) <BR> 27 * <BR> 28 * The implementation supports "SHA1PRNG", "SHA-1" and "SHA1withDSA" algorithms described in 29 * JavaTM Cryptography Architecture, API Specification & Reference 30 */ 31 32 public final class CryptoProvider extends Provider { 33 34 private static final long serialVersionUID = 7991202868423459598L; 35 36 /** 37 * Creates a Provider and puts parameters 38 */ 39 public CryptoProvider() { 40 41 super("Crypto", 1.0, 42 "HARMONY (SHA1 digest; SecureRandom; SHA1withDSA signature)"); 43 44 // names of classes implementing services 45 final String MD_NAME = "org.apache.harmony.security.provider.crypto.SHA1_MessageDigestImpl"; 46 final String SR_NAME = "org.apache.harmony.security.provider.crypto.SHA1PRNG_SecureRandomImpl"; 47 48 final String SIGN_NAME = "org.apache.harmony.security.provider.crypto.SHA1withDSA_SignatureImpl"; 49 50 final String SIGN_ALIAS = "SHA1withDSA"; 51 52 53 final String KEYF_NAME = 54 "org.apache.harmony.security.provider.crypto.DSAKeyFactoryImpl"; 55 56 AccessController.doPrivileged(new java.security.PrivilegedAction<Void>() { 57 58 public Void run() { 59 60 put("MessageDigest.SHA-1", MD_NAME); 61 put("MessageDigest.SHA-1 ImplementedIn", "Software"); 62 put("Alg.Alias.MessageDigest.SHA1", "SHA-1"); 63 put("Alg.Alias.MessageDigest.SHA", "SHA-1"); 64 65 if (RandomBitsSupplier.isServiceAvailable()) { 66 put("SecureRandom.SHA1PRNG", SR_NAME); 67 put("SecureRandom.SHA1PRNG ImplementedIn", "Software"); 68 } 69 70 put("Signature.SHA1withDSA", SIGN_NAME); 71 put("Signature.SHA1withDSA ImplementedIn", "Software"); 72 put("Alg.Alias.Signature.SHAwithDSA", SIGN_ALIAS); 73 put("Alg.Alias.Signature.DSAwithSHA1", SIGN_ALIAS); 74 put("Alg.Alias.Signature.SHA1/DSA", SIGN_ALIAS); 75 put("Alg.Alias.Signature.SHA/DSA", SIGN_ALIAS); 76 put("Alg.Alias.Signature.SHA-1/DSA", SIGN_ALIAS); 77 put("Alg.Alias.Signature.DSA", SIGN_ALIAS); 78 put("Alg.Alias.Signature.DSS", SIGN_ALIAS); 79 80 put("Alg.Alias.Signature.OID.1.2.840.10040.4.3", SIGN_ALIAS); 81 put("Alg.Alias.Signature.1.2.840.10040.4.3", SIGN_ALIAS); 82 put("Alg.Alias.Signature.1.3.14.3.2.13", SIGN_ALIAS); 83 put("Alg.Alias.Signature.1.3.14.3.2.27", SIGN_ALIAS); 84 85 put("KeyFactory.DSA", KEYF_NAME); 86 put("KeyFactory.DSA ImplementedIn", "Software"); 87 put("Alg.Alias.KeyFactory.1.3.14.3.2.12", "DSA"); 88 put("Alg.Alias.KeyFactory.1.2.840.10040.4.1", "DSA"); 89 90 return null; 91 } 92 }); 93 } 94 } 95