2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
18 using System.Collections;
20 namespace Tizen.Security.SecureRepository.Crypto
23 /// A abstract class holding parameters for signing and verification.
25 abstract public class SignatureParameters
27 private Hashtable _parameters;
30 /// A constructor with algorithm
32 /// <param name="algorithm">An algorithm that this parameters are prepared for.</param>
33 protected SignatureParameters(SignatureAlgorithmType algorithm)
35 _parameters = new Hashtable();
36 Add(SignatureParameterName.AlgorithmType, (int)algorithm);
40 /// Signature algorithm type.
42 public SignatureAlgorithmType SignatureAlgorithm
44 get { return (SignatureAlgorithmType)Get(SignatureParameterName.AlgorithmType); }
48 /// Hash algorithm used in signing anve verification.
50 public HashAlgorithm HashAlgorithm
52 get { return (HashAlgorithm)Get(SignatureParameterName.HashAlgorithm); }
53 set { Add(SignatureParameterName.HashAlgorithm, (int)value); }
57 /// Adds integer parameter.
59 /// <param name="name">Parameter name.</param>
60 /// <param name="value">Parameter value.</param>
61 internal void Add(SignatureParameterName name, int value)
63 _parameters.Add((int)name, value);
67 /// Gets integer parameter.
69 /// <param name="name">Parameter name.</param>
70 internal int Get(SignatureParameterName name)
72 if (_parameters.ContainsKey((int)name))
73 return (int)_parameters[(int)name];
75 throw new ArgumentException("No parameter for a given SignatureParameterName ");