// Convert an ASN.1 buffer into DSA private parameters. internal void ASN1ToPrivate(ASN1Parser parser) { parser = parser.GetSequence(); P = parser.GetBigInt(); Q = parser.GetBigInt(); G = parser.GetBigInt(); Y = parser.GetBigInt(); J = parser.GetBigInt(); X = parser.GetBigInt(); Seed = parser.GetBigInt(); Counter = parser.GetInt32(); parser.AtEnd(); }
// Convert an ASN.1 buffer into DSA public parameters. internal void ASN1ToPublic(ASN1Parser parser) { parser = parser.GetSequence(); if (parser.Type == ASN1Type.Sequence) { // This looks like it may be a "SubjectPublicKeyInfo" // from an X.509 certificate. Validate the algorithm ID. ASN1Parser alg = parser.GetSequence(); byte[] objid = alg.GetObjectIdentifier(); if (!ASN1Parser.IsObjectID(objid, dsaID)) { throw new CryptographicException (_("Crypto_InvalidASN1")); } // Get the common P, Q, and G parameters. ASN1Parser algParams = alg.GetSequence(); P = algParams.GetBigInt(); Q = algParams.GetBigInt(); G = algParams.GetBigInt(); algParams.AtEnd(); alg.AtEnd(); // Get the public key information (Y). ASN1Parser bitString = parser.GetBitStringContents(); Y = bitString.GetBigInt(); bitString.AtEnd(); parser.AtEnd(); } else { // This looks like a bare list of DSA parameters. P = parser.GetBigInt(); Q = parser.GetBigInt(); G = parser.GetBigInt(); Y = parser.GetBigInt(); if (!parser.IsAtEnd()) { // It looks like we have private DSA parameters also. J = parser.GetBigInt(); X = parser.GetBigInt(); Seed = parser.GetBigInt(); Counter = parser.GetInt32(); } parser.AtEnd(); } }
// Convert an ASN.1 buffer into RSA private parameters. internal void ASN1ToPrivate(ASN1Parser parser) { parser = parser.GetSequence(); if (parser.GetInt32() != 0) { // Incorrect version for RSA private key parameters. throw new CryptographicException (_("Crypto_InvalidASN1")); } Modulus = parser.GetBigInt(); Exponent = parser.GetBigInt(); D = parser.GetBigInt(); P = parser.GetBigInt(); Q = parser.GetBigInt(); DP = parser.GetBigInt(); DQ = parser.GetBigInt(); InverseQ = parser.GetBigInt(); parser.AtEnd(); }
// Convert an ASN.1 buffer into RSA private parameters. internal void ASN1ToPrivate(ASN1Parser parser) { parser = parser.GetSequence(); if(parser.GetInt32() != 0) { // Incorrect version for RSA private key parameters. throw new CryptographicException (_("Crypto_InvalidASN1")); } Modulus = parser.GetBigInt(); Exponent = parser.GetBigInt(); D = parser.GetBigInt(); P = parser.GetBigInt(); Q = parser.GetBigInt(); DP = parser.GetBigInt(); DQ = parser.GetBigInt(); InverseQ = parser.GetBigInt(); parser.AtEnd(); }
// Convert an ASN.1 buffer into DSA private parameters. internal void ASN1ToPrivate(ASN1Parser parser) { parser = parser.GetSequence(); P = parser.GetBigInt(); Q = parser.GetBigInt(); G = parser.GetBigInt(); Y = parser.GetBigInt(); J = parser.GetBigInt(); X = parser.GetBigInt(); Seed = parser.GetBigInt(); Counter = parser.GetInt32(); parser.AtEnd(); }
// Convert an ASN.1 buffer into DSA public parameters. internal void ASN1ToPublic(ASN1Parser parser) { parser = parser.GetSequence(); if(parser.Type == ASN1Type.Sequence) { // This looks like it may be a "SubjectPublicKeyInfo" // from an X.509 certificate. Validate the algorithm ID. ASN1Parser alg = parser.GetSequence(); byte[] objid = alg.GetObjectIdentifier(); if(!ASN1Parser.IsObjectID(objid, dsaID)) { throw new CryptographicException (_("Crypto_InvalidASN1")); } // Get the common P, Q, and G parameters. ASN1Parser algParams = alg.GetSequence(); P = algParams.GetBigInt(); Q = algParams.GetBigInt(); G = algParams.GetBigInt(); algParams.AtEnd(); alg.AtEnd(); // Get the public key information (Y). ASN1Parser bitString = parser.GetBitStringContents(); Y = bitString.GetBigInt(); bitString.AtEnd(); parser.AtEnd(); } else { // This looks like a bare list of DSA parameters. P = parser.GetBigInt(); Q = parser.GetBigInt(); G = parser.GetBigInt(); Y = parser.GetBigInt(); if(!parser.IsAtEnd()) { // It looks like we have private DSA parameters also. J = parser.GetBigInt(); X = parser.GetBigInt(); Seed = parser.GetBigInt(); Counter = parser.GetInt32(); } parser.AtEnd(); } }