protected override void Decode() { this.cA = false; this.pathLenConstraint = -1; ASN1 asN1_1 = new ASN1(this.extnValue.Value); if (asN1_1.Tag != (byte)48) { throw new ArgumentException("Invalid BasicConstraints extension"); } int num1 = 0; ASN1 asN1_2 = asN1_1; int index1 = num1; int num2 = index1 + 1; ASN1 asn1 = asN1_2[index1]; if (asn1 != null && asn1.Tag == (byte)1) { this.cA = asn1.Value[0] == byte.MaxValue; ASN1 asN1_3 = asN1_1; int index2 = num2; int num3 = index2 + 1; asn1 = asN1_3[index2]; } if (asn1 == null || asn1.Tag != (byte)2) { return; } this.pathLenConstraint = ASN1Convert.ToInt32(asn1); }
protected override void Decode() { // default values cA = false; pathLenConstraint = NoPathLengthConstraint; ASN1 sequence = new ASN1(extnValue.Value); if (sequence.Tag != 0x30) { throw new ArgumentException("Invalid BasicConstraints extension"); } int n = 0; ASN1 a = sequence [n++]; if ((a != null) && (a.Tag == 0x01)) { cA = (a.Value [0] == 0xFF); a = sequence [n++]; } if ((a != null) && (a.Tag == 0x02)) { pathLenConstraint = ASN1Convert.ToInt32(a); } }
public void ConvertInt32_One() { Int32 expected = 1; ASN1 integer = ASN1Convert.FromInt32(expected); Int32 actual = ASN1Convert.ToInt32(integer); Assert.AreEqual(expected, actual, "Int32_Zero"); }
public void ConvertInt32_Positive() { Int32 expected = Int32.MaxValue; ASN1 integer = ASN1Convert.FromInt32(expected); Int32 actual = ASN1Convert.ToInt32(integer); Assert.AreEqual(expected, actual, "Int32_Positive"); }
public void ConvertInt32_Negative() { Int32 expected = -1; ASN1 integer = ASN1Convert.FromInt32(expected); Int32 actual = ASN1Convert.ToInt32(integer); Assert.AreEqual(expected, actual, "Int32_Negative"); }
// methods private void Decode(byte[] data) { ASN1 encryptedPrivateKeyInfo = new ASN1(data); if (encryptedPrivateKeyInfo.Tag != 0x30) { throw new CryptographicException("invalid EncryptedPrivateKeyInfo"); } ASN1 encryptionAlgorithm = encryptedPrivateKeyInfo [0]; if (encryptionAlgorithm.Tag != 0x30) { throw new CryptographicException("invalid encryptionAlgorithm"); } ASN1 algorithm = encryptionAlgorithm [0]; if (algorithm.Tag != 0x06) { throw new CryptographicException("invalid algorithm"); } _algorithm = ASN1Convert.ToOid(algorithm); // parameters ANY DEFINED BY algorithm OPTIONAL if (encryptionAlgorithm.Count > 1) { ASN1 parameters = encryptionAlgorithm [1]; if (parameters.Tag != 0x30) { throw new CryptographicException("invalid parameters"); } ASN1 salt = parameters [0]; if (salt.Tag != 0x04) { throw new CryptographicException("invalid salt"); } _salt = salt.Value; ASN1 iterationCount = parameters [1]; if (iterationCount.Tag != 0x02) { throw new CryptographicException("invalid iterationCount"); } _iterations = ASN1Convert.ToInt32(iterationCount); } ASN1 encryptedData = encryptedPrivateKeyInfo [1]; if (encryptedData.Tag != 0x04) { throw new CryptographicException("invalid EncryptedData"); } _data = encryptedData.Value; }
private void Decode(byte[] data) { ASN1 aSN = new ASN1(data); if (aSN.Tag != 48) { throw new CryptographicException("invalid EncryptedPrivateKeyInfo"); } ASN1 aSN2 = aSN[0]; if (aSN2.Tag != 48) { throw new CryptographicException("invalid encryptionAlgorithm"); } ASN1 aSN3 = aSN2[0]; if (aSN3.Tag != 6) { throw new CryptographicException("invalid algorithm"); } _algorithm = ASN1Convert.ToOid(aSN3); if (aSN2.Count > 1) { ASN1 aSN4 = aSN2[1]; if (aSN4.Tag != 48) { throw new CryptographicException("invalid parameters"); } ASN1 aSN5 = aSN4[0]; if (aSN5.Tag != 4) { throw new CryptographicException("invalid salt"); } _salt = aSN5.Value; ASN1 aSN6 = aSN4[1]; if (aSN6.Tag != 2) { throw new CryptographicException("invalid iterationCount"); } _iterations = ASN1Convert.ToInt32(aSN6); } ASN1 aSN7 = aSN[1]; if (aSN7.Tag != 4) { throw new CryptographicException("invalid EncryptedData"); } _data = aSN7.Value; }
private void Decode(byte[] data) { ASN1 asn = new ASN1(data); if (asn.Tag != 48) { throw new CryptographicException("invalid EncryptedPrivateKeyInfo"); } ASN1 asn2 = asn[0]; if (asn2.Tag != 48) { throw new CryptographicException("invalid encryptionAlgorithm"); } ASN1 asn3 = asn2[0]; if (asn3.Tag != 6) { throw new CryptographicException("invalid algorithm"); } this._algorithm = ASN1Convert.ToOid(asn3); if (asn2.Count > 1) { ASN1 asn4 = asn2[1]; if (asn4.Tag != 48) { throw new CryptographicException("invalid parameters"); } ASN1 asn5 = asn4[0]; if (asn5.Tag != 4) { throw new CryptographicException("invalid salt"); } this._salt = asn5.Value; ASN1 asn6 = asn4[1]; if (asn6.Tag != 2) { throw new CryptographicException("invalid iterationCount"); } this._iterations = ASN1Convert.ToInt32(asn6); } ASN1 asn7 = asn[1]; if (asn7.Tag != 4) { throw new CryptographicException("invalid EncryptedData"); } this._data = asn7.Value; }
private void Decode(byte[] data) { ASN1 asN1_1 = new ASN1(data); if (asN1_1.Tag != (byte)48) { throw new CryptographicException("invalid EncryptedPrivateKeyInfo"); } ASN1 asN1_2 = asN1_1[0]; if (asN1_2.Tag != (byte)48) { throw new CryptographicException("invalid encryptionAlgorithm"); } ASN1 asn1_1 = asN1_2[0]; if (asn1_1.Tag != (byte)6) { throw new CryptographicException("invalid algorithm"); } this._algorithm = ASN1Convert.ToOid(asn1_1); if (asN1_2.Count > 1) { ASN1 asN1_3 = asN1_2[1]; if (asN1_3.Tag != (byte)48) { throw new CryptographicException("invalid parameters"); } ASN1 asN1_4 = asN1_3[0]; if (asN1_4.Tag != (byte)4) { throw new CryptographicException("invalid salt"); } this._salt = asN1_4.Value; ASN1 asn1_2 = asN1_3[1]; if (asn1_2.Tag != (byte)2) { throw new CryptographicException("invalid iterationCount"); } this._iterations = ASN1Convert.ToInt32(asn1_2); } ASN1 asN1_5 = asN1_1[1]; if (asN1_5.Tag != (byte)4) { throw new CryptographicException("invalid EncryptedData"); } this._data = asN1_5.Value; }
// internal internal AsnDecodeStatus Decode(byte[] extension) { if ((extension == null) || (extension.Length == 0)) { return(AsnDecodeStatus.BadAsn); } if (extension [0] != 0x30) { return(AsnDecodeStatus.BadTag); } if (extension.Length < 3) { if (!((extension.Length == 2) && (extension [1] == 0x00))) { return(AsnDecodeStatus.BadLength); } } try { ASN1 sequence = new ASN1(extension); int n = 0; ASN1 a = sequence [n++]; if ((a != null) && (a.Tag == 0x01)) { _certificateAuthority = (a.Value [0] == 0xFF); a = sequence [n++]; } if ((a != null) && (a.Tag == 0x02)) { _hasPathLengthConstraint = true; _pathLengthConstraint = ASN1Convert.ToInt32(a); } } catch { return(AsnDecodeStatus.BadAsn); } return(AsnDecodeStatus.Ok); }
protected override void Decode() { cA = false; pathLenConstraint = -1; ASN1 aSN = new ASN1(extnValue.Value); if (aSN.Tag != 48) { throw new ArgumentException("Invalid BasicConstraints extension"); } int num = 0; ASN1 aSN2 = aSN[num++]; if (aSN2 != null && aSN2.Tag == 1) { cA = (aSN2.Value[0] == byte.MaxValue); aSN2 = aSN[num++]; } if (aSN2 != null && aSN2.Tag == 2) { pathLenConstraint = ASN1Convert.ToInt32(aSN2); } }
protected override void Decode() { this.cA = false; this.pathLenConstraint = -1; ASN1 asn = new ASN1(this.extnValue.Value); if (asn.Tag != 48) { throw new ArgumentException("Invalid BasicConstraints extension"); } int num = 0; ASN1 asn2 = asn[num++]; if (asn2 != null && asn2.Tag == 1) { this.cA = (asn2.Value[0] == byte.MaxValue); asn2 = asn[num++]; } if (asn2 != null && asn2.Tag == 2) { this.pathLenConstraint = ASN1Convert.ToInt32(asn2); } }
internal AsnDecodeStatus Decode(byte[] extension) { if (extension == null || extension.Length == 0) { return(AsnDecodeStatus.BadAsn); } if (extension[0] != 48) { return(AsnDecodeStatus.BadTag); } if (extension.Length < 3 && (extension.Length != 2 || extension[1] != 0)) { return(AsnDecodeStatus.BadLength); } try { ASN1 asn = new ASN1(extension); int num = 0; ASN1 asn2 = asn[num++]; if (asn2 != null && asn2.Tag == 1) { this._certificateAuthority = (asn2.Value[0] == byte.MaxValue); asn2 = asn[num++]; } if (asn2 != null && asn2.Tag == 2) { this._hasPathLengthConstraint = true; this._pathLengthConstraint = ASN1Convert.ToInt32(asn2); } } catch { return(AsnDecodeStatus.BadAsn); } return(AsnDecodeStatus.Ok); }
public void ConvertToInt32_Null() { ASN1Convert.ToInt32(null); }
public void ConvertToInt32_WrongTag() { ASN1 nul = new ASN1(0x05); Int32 actual = ASN1Convert.ToInt32(nul); }