Class SExprParser
java.lang.Object
org.eclipse.jgit.gpg.bc.internal.keys.SExprParser
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
FieldsModifier and TypeFieldDescriptionprivate final org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider
-
Constructor Summary
ConstructorsConstructorDescriptionSExprParser
(org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider digestProvider) Base constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate static byte[][]
extractData
(InputStream inputStream, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory) org.bouncycastle.openpgp.PGPSecretKey
parseSecretKey
(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
(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 BigInteger
processDSASecretKey
(InputStream inputStream, BigInteger p, BigInteger q, BigInteger g, BigInteger y, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory) private BigInteger
processECSecretKey
(InputStream inputStream, String curveID, String curveName, byte[] qVal, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory) private BigInteger
processElGamalSecretKey
(InputStream inputStream, BigInteger p, BigInteger g, BigInteger y, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory) private BigInteger[]
processRSASecretKey
(InputStream inputStream, BigInteger n, BigInteger e, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory) private BigInteger
readBigInteger
(String expectedType, InputStream inputStream) private void
writeCanonical
(OutputStream dOut, String label, byte[] data) private void
writeCanonical
(OutputStream dOut, String label, BigInteger i)
-
Field Details
-
digestProvider
private final org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider digestProvider
-
-
Constructor Details
-
SExprParser
public SExprParser(org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider digestProvider) Base constructor.- Parameters:
digestProvider
- a provider for digest calculations. Used to confirm key protection hashes.
-
-
Method Details
-
parseSecretKey
public org.bouncycastle.openpgp.PGPSecretKey parseSecretKey(InputStream inputStream, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory, org.bouncycastle.openpgp.PGPPublicKey pubKey) throws 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:
IOException
org.bouncycastle.openpgp.PGPException
-
parseSecretKey
public org.bouncycastle.openpgp.PGPSecretKey parseSecretKey(InputStream inputStream, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory, org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator fingerPrintCalculator) throws 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:
IOException
org.bouncycastle.openpgp.PGPException
-
readBigInteger
private BigInteger readBigInteger(String expectedType, InputStream inputStream) throws IOException, org.bouncycastle.openpgp.PGPException - Throws:
IOException
org.bouncycastle.openpgp.PGPException
-
extractData
private static byte[][] extractData(InputStream inputStream, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory) throws org.bouncycastle.openpgp.PGPException, IOException - Throws:
org.bouncycastle.openpgp.PGPException
IOException
-
processDSASecretKey
private BigInteger processDSASecretKey(InputStream inputStream, BigInteger p, BigInteger q, BigInteger g, BigInteger y, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory) throws IOException, org.bouncycastle.openpgp.PGPException - Throws:
IOException
org.bouncycastle.openpgp.PGPException
-
processElGamalSecretKey
private BigInteger processElGamalSecretKey(InputStream inputStream, BigInteger p, BigInteger g, BigInteger y, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory) throws IOException, org.bouncycastle.openpgp.PGPException - Throws:
IOException
org.bouncycastle.openpgp.PGPException
-
processECSecretKey
private BigInteger processECSecretKey(InputStream inputStream, String curveID, String curveName, byte[] qVal, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory) throws IOException, org.bouncycastle.openpgp.PGPException - Throws:
IOException
org.bouncycastle.openpgp.PGPException
-
processRSASecretKey
private BigInteger[] processRSASecretKey(InputStream inputStream, BigInteger n, BigInteger e, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory) throws IOException, org.bouncycastle.openpgp.PGPException - Throws:
IOException
org.bouncycastle.openpgp.PGPException
-
writeCanonical
- Throws:
IOException
-
writeCanonical
- Throws:
IOException
-