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: /**
019: * @author Vladimir N. Molotkov
020: * @version $Revision$
021: */package java.security.spec;
022:
023: import org.apache.harmony.security.internal.nls.Messages;
024:
025: /**
026: * @com.intel.drl.spec_ref
027: *
028: */
029: public class PSSParameterSpec implements AlgorithmParameterSpec {
030: /**
031: * @com.intel.drl.spec_ref
032: */
033: public static final PSSParameterSpec DEFAULT = new PSSParameterSpec(
034: 20);
035:
036: // Message digest algorithm name
037: private final String mdName;
038: // Mask generation function algorithm name
039: private final String mgfName;
040: // Mask generation function parameters
041: private final AlgorithmParameterSpec mgfSpec;
042: // Trailer field value
043: private final int trailerField;
044: // Salt length in bits
045: private final int saltLen;
046:
047: /**
048: * @com.intel.drl.spec_ref
049: */
050: public PSSParameterSpec(int saltLen) {
051: if (saltLen < 0) {
052: throw new IllegalArgumentException(Messages
053: .getString("security.7F")); //$NON-NLS-1$
054: }
055: this .saltLen = saltLen;
056: this .mdName = "SHA-1"; //$NON-NLS-1$
057: this .mgfName = "MGF1"; //$NON-NLS-1$
058: this .mgfSpec = MGF1ParameterSpec.SHA1;
059: this .trailerField = 1;
060: }
061:
062: /**
063: * @com.intel.drl.spec_ref *
064: */
065: public PSSParameterSpec(String mdName, String mgfName,
066: AlgorithmParameterSpec mgfSpec, int saltLen,
067: int trailerField) {
068:
069: if (mdName == null) {
070: throw new NullPointerException(Messages
071: .getString("security.80")); //$NON-NLS-1$
072: }
073: if (mgfName == null) {
074: throw new NullPointerException(Messages
075: .getString("security.81")); //$NON-NLS-1$
076: }
077: if (saltLen < 0) {
078: throw new IllegalArgumentException(Messages
079: .getString("security.7F")); //$NON-NLS-1$
080: }
081: if (trailerField < 0) {
082: throw new IllegalArgumentException(Messages
083: .getString("security.82")); //$NON-NLS-1$
084: }
085: this .mdName = mdName;
086: this .mgfName = mgfName;
087: this .mgfSpec = mgfSpec;
088: this .saltLen = saltLen;
089: this .trailerField = trailerField;
090: }
091:
092: /**
093: * @com.intel.drl.spec_ref
094: */
095: public int getSaltLength() {
096: return saltLen;
097: }
098:
099: /**
100: * @com.intel.drl.spec_ref
101: */
102: public String getDigestAlgorithm() {
103: return mdName;
104: }
105:
106: /**
107: * @com.intel.drl.spec_ref
108: */
109: public String getMGFAlgorithm() {
110: return mgfName;
111: }
112:
113: /**
114: * @com.intel.drl.spec_ref
115: */
116: public AlgorithmParameterSpec getMGFParameters() {
117: return mgfSpec;
118: }
119:
120: /**
121: * @com.intel.drl.spec_ref
122: */
123: public int getTrailerField() {
124: return trailerField;
125: }
126: }
|