The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 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 | |
Jesse Wilson | 7365de1 | 2010-08-11 15:21:19 -0700 | [diff] [blame] | 20 | import java.security.Provider; |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * Implementation of Provider for SecureRandom, MessageDigest and Signature |
| 24 | * using a Secure Hash Algorithm, SHA-1; |
| 25 | * see SECURE HASH STANDARD, FIPS PUB 180-1 (http://www.itl.nist.gov/fipspubs/fip180-1.htm) <BR> |
| 26 | * <BR> |
| 27 | * The implementation supports "SHA1PRNG", "SHA-1" and "SHA1withDSA" algorithms described in |
| 28 | * JavaTM Cryptography Architecture, API Specification & Reference |
| 29 | */ |
| 30 | |
| 31 | public final class CryptoProvider extends Provider { |
| 32 | |
| 33 | private static final long serialVersionUID = 7991202868423459598L; |
| 34 | |
| 35 | /** |
| 36 | * Creates a Provider and puts parameters |
| 37 | */ |
| 38 | public CryptoProvider() { |
| 39 | |
Elliott Hughes | ad41624 | 2011-01-06 18:13:31 -0800 | [diff] [blame^] | 40 | super("Crypto", 1.0, "HARMONY (SHA1 digest; SecureRandom; SHA1withDSA signature)"); |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 41 | |
| 42 | // names of classes implementing services |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame] | 43 | final String MD_NAME = "org.apache.harmony.security.provider.crypto.SHA1_MessageDigestImpl"; |
| 44 | final String SR_NAME = "org.apache.harmony.security.provider.crypto.SHA1PRNG_SecureRandomImpl"; |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 45 | |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame] | 46 | final String SIGN_NAME = "org.apache.harmony.security.provider.crypto.SHA1withDSA_SignatureImpl"; |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 47 | |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame] | 48 | final String SIGN_ALIAS = "SHA1withDSA"; |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 49 | |
| 50 | |
Elliott Hughes | ad41624 | 2011-01-06 18:13:31 -0800 | [diff] [blame^] | 51 | final String KEYF_NAME = "org.apache.harmony.security.provider.crypto.DSAKeyFactoryImpl"; |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 52 | |
Elliott Hughes | ad41624 | 2011-01-06 18:13:31 -0800 | [diff] [blame^] | 53 | put("MessageDigest.SHA-1", MD_NAME); |
| 54 | put("MessageDigest.SHA-1 ImplementedIn", "Software"); |
| 55 | put("Alg.Alias.MessageDigest.SHA1", "SHA-1"); |
| 56 | put("Alg.Alias.MessageDigest.SHA", "SHA-1"); |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 57 | |
Elliott Hughes | ad41624 | 2011-01-06 18:13:31 -0800 | [diff] [blame^] | 58 | if (RandomBitsSupplier.isServiceAvailable()) { |
| 59 | put("SecureRandom.SHA1PRNG", SR_NAME); |
| 60 | put("SecureRandom.SHA1PRNG ImplementedIn", "Software"); |
| 61 | } |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 62 | |
Elliott Hughes | ad41624 | 2011-01-06 18:13:31 -0800 | [diff] [blame^] | 63 | put("Signature.SHA1withDSA", SIGN_NAME); |
| 64 | put("Signature.SHA1withDSA ImplementedIn", "Software"); |
| 65 | put("Alg.Alias.Signature.SHAwithDSA", SIGN_ALIAS); |
| 66 | put("Alg.Alias.Signature.DSAwithSHA1", SIGN_ALIAS); |
| 67 | put("Alg.Alias.Signature.SHA1/DSA", SIGN_ALIAS); |
| 68 | put("Alg.Alias.Signature.SHA/DSA", SIGN_ALIAS); |
| 69 | put("Alg.Alias.Signature.SHA-1/DSA", SIGN_ALIAS); |
| 70 | put("Alg.Alias.Signature.DSA", SIGN_ALIAS); |
| 71 | put("Alg.Alias.Signature.DSS", SIGN_ALIAS); |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 72 | |
Elliott Hughes | ad41624 | 2011-01-06 18:13:31 -0800 | [diff] [blame^] | 73 | put("Alg.Alias.Signature.OID.1.2.840.10040.4.3", SIGN_ALIAS); |
| 74 | put("Alg.Alias.Signature.1.2.840.10040.4.3", SIGN_ALIAS); |
| 75 | put("Alg.Alias.Signature.1.3.14.3.2.13", SIGN_ALIAS); |
| 76 | put("Alg.Alias.Signature.1.3.14.3.2.27", SIGN_ALIAS); |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 77 | |
Elliott Hughes | ad41624 | 2011-01-06 18:13:31 -0800 | [diff] [blame^] | 78 | put("KeyFactory.DSA", KEYF_NAME); |
| 79 | put("KeyFactory.DSA ImplementedIn", "Software"); |
| 80 | put("Alg.Alias.KeyFactory.1.3.14.3.2.12", "DSA"); |
| 81 | put("Alg.Alias.KeyFactory.1.2.840.10040.4.1", "DSA"); |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 82 | } |
| 83 | } |