Esempio n. 1
0
        private void CheckAlg(bool decode)
        {
            AlgorithmId algorithmId = null;

            foreach (var alg in PkiConstants.SupportedAlgorithms)
            {
                if (alg.Id.Equals(Algorithm))
                {
                    algorithmId = alg;
                    break;
                }
            }

            if ((algorithmId != null) && ((decode && (Parameters != null)) && (algorithmId.Type != null)))
            {
                try
                {
                    var buffer = new Asn1BerDecodeBuffer(((Asn1OpenType)Parameters).Value);
                    Parameters = (Asn1Type)Activator.CreateInstance(algorithmId.Type.GetType());
                    Parameters.Decode(buffer, true, 0);
                    buffer.InvokeEndElement("parameters", -1);
                }
                catch (Exception exception)
                {
                    Asn1Util.WriteStackTrace(exception, Console.Error);
                    throw ExceptionUtility.CryptographicException(Resources.Asn1TableConstraint);
                }
            }
        }
Esempio n. 2
0
        public void checkTC(bool decode)
        {
            /* check algorithm */
            ALGORITHM_ID _index = null;

            for (int i = 0; i < _PKIX1Explicit88Values.SupportedAlgorithms.Length; i++)
            {
                if (_PKIX1Explicit88Values.SupportedAlgorithms[i].id.Equals(algorithm))
                {
                    _index = _PKIX1Explicit88Values.SupportedAlgorithms[i];
                    break;
                }
            }
            if (null == _index)
            {
                return;
            }

            /* check parameters */
            if (decode)
            {
                if (parameters != null && _index.Type != null)
                {
                    try {
                        Asn1BerDecodeBuffer buffer = new Asn1BerDecodeBuffer(((Asn1OpenType)parameters).Value);
                        parameters = (Asn1Type)System.Activator.CreateInstance(_index.Type.GetType());
                        parameters.Decode(buffer, Asn1Tag.EXPL, 0);
                        buffer.InvokeEndElement("parameters", -1);
                    }
                    catch (Exception e) {
                        //Asn1Util.WriteStackTrace(e, Console.Error);
                        //throw new Exception("Asn1Exception(table constraint: parameters decode failed)");
                        throw e;
                    }
                }
            }
        }