Class SExprParser
- java.lang.Object
-
- org.eclipse.jgit.gpg.bc.internal.keys.SExprParser
-
public class SExprParser extends java.lang.Object
A parser for secret keys stored in s-expressions. Original BouncyCastle code modified by the JGit team to:- handle unencrypted DSA, EC, and ElGamal keys (upstream only handles unencrypted RSA), and
- handle secret keys using AES/OCB as encryption (those don't have a hash).
-
-
Field Summary
Fields Modifier and Type Field Description private org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider
digestProvider
-
Constructor Summary
Constructors Constructor Description SExprParser(org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider digestProvider)
Base constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static byte[][]
extractData(java.io.InputStream inputStream, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory)
org.bouncycastle.openpgp.PGPSecretKey
parseSecretKey(java.io.InputStream inputStream, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory, org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator fingerPrintCalculator)
Parse a secret key from one of the GPG S expression keys.org.bouncycastle.openpgp.PGPSecretKey
parseSecretKey(java.io.InputStream inputStream, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory, org.bouncycastle.openpgp.PGPPublicKey pubKey)
Parse a secret key from one of the GPG S expression keys associating it with the passed in public key.private java.math.BigInteger
processDSASecretKey(java.io.InputStream inputStream, java.math.BigInteger p, java.math.BigInteger q, java.math.BigInteger g, java.math.BigInteger y, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory)
private java.math.BigInteger
processECSecretKey(java.io.InputStream inputStream, java.lang.String curveID, java.lang.String curveName, byte[] qVal, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory)
private java.math.BigInteger
processElGamalSecretKey(java.io.InputStream inputStream, java.math.BigInteger p, java.math.BigInteger g, java.math.BigInteger y, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory)
private java.math.BigInteger[]
processRSASecretKey(java.io.InputStream inputStream, java.math.BigInteger n, java.math.BigInteger e, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory)
private java.math.BigInteger
readBigInteger(java.lang.String expectedType, java.io.InputStream inputStream)
private void
writeCanonical(java.io.OutputStream dOut, java.lang.String label, byte[] data)
private void
writeCanonical(java.io.OutputStream dOut, java.lang.String label, java.math.BigInteger i)
-
-
-
Method Detail
-
parseSecretKey
public org.bouncycastle.openpgp.PGPSecretKey parseSecretKey(java.io.InputStream inputStream, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory, org.bouncycastle.openpgp.PGPPublicKey pubKey) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
Parse a secret key from one of the GPG S expression keys associating it with the passed in public key.- Parameters:
inputStream
- to read fromkeyProtectionRemoverFactory
- for decrypting encrypted keyspubKey
- the private key should belong to- Returns:
- a secret key object.
- Throws:
java.io.IOException
org.bouncycastle.openpgp.PGPException
-
parseSecretKey
public org.bouncycastle.openpgp.PGPSecretKey parseSecretKey(java.io.InputStream inputStream, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory, org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator fingerPrintCalculator) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
Parse a secret key from one of the GPG S expression keys.- Parameters:
inputStream
- to read fromkeyProtectionRemoverFactory
- for decrypting encrypted keysfingerPrintCalculator
- for calculating key fingerprints- Returns:
- a secret key object.
- Throws:
java.io.IOException
org.bouncycastle.openpgp.PGPException
-
readBigInteger
private java.math.BigInteger readBigInteger(java.lang.String expectedType, java.io.InputStream inputStream) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
- Throws:
java.io.IOException
org.bouncycastle.openpgp.PGPException
-
extractData
private static byte[][] extractData(java.io.InputStream inputStream, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory) throws org.bouncycastle.openpgp.PGPException, java.io.IOException
- Throws:
org.bouncycastle.openpgp.PGPException
java.io.IOException
-
processDSASecretKey
private java.math.BigInteger processDSASecretKey(java.io.InputStream inputStream, java.math.BigInteger p, java.math.BigInteger q, java.math.BigInteger g, java.math.BigInteger y, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
- Throws:
java.io.IOException
org.bouncycastle.openpgp.PGPException
-
processElGamalSecretKey
private java.math.BigInteger processElGamalSecretKey(java.io.InputStream inputStream, java.math.BigInteger p, java.math.BigInteger g, java.math.BigInteger y, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
- Throws:
java.io.IOException
org.bouncycastle.openpgp.PGPException
-
processECSecretKey
private java.math.BigInteger processECSecretKey(java.io.InputStream inputStream, java.lang.String curveID, java.lang.String curveName, byte[] qVal, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
- Throws:
java.io.IOException
org.bouncycastle.openpgp.PGPException
-
processRSASecretKey
private java.math.BigInteger[] processRSASecretKey(java.io.InputStream inputStream, java.math.BigInteger n, java.math.BigInteger e, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
- Throws:
java.io.IOException
org.bouncycastle.openpgp.PGPException
-
writeCanonical
private void writeCanonical(java.io.OutputStream dOut, java.lang.String label, java.math.BigInteger i) throws java.io.IOException
- Throws:
java.io.IOException
-
writeCanonical
private void writeCanonical(java.io.OutputStream dOut, java.lang.String label, byte[] data) throws java.io.IOException
- Throws:
java.io.IOException
-
-