Return the raw signature instead of a PGPSignature in
AuthenticationSignatureGenerator
This commit is contained in:
parent
f70b10d548
commit
2dba6e3cb0
|
@ -218,7 +218,7 @@ public class AuthenticationOperation extends BaseOperation<AuthenticationParcel>
|
||||||
signatureGenerator.update(challenge, 0, challenge.length);
|
signatureGenerator.update(challenge, 0, challenge.length);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
signature = signatureGenerator.generate().getSignature();
|
signature = signatureGenerator.getSignature();
|
||||||
} catch (NfcSyncPGPContentSignerBuilder.NfcInteractionNeeded e) {
|
} catch (NfcSyncPGPContentSignerBuilder.NfcInteractionNeeded e) {
|
||||||
// this secret key diverts to a OpenPGP card, thus requires user interaction
|
// this secret key diverts to a OpenPGP card, thus requires user interaction
|
||||||
log.add(LogType.MSG_AUTH_PENDING_NFC, indent);
|
log.add(LogType.MSG_AUTH_PENDING_NFC, indent);
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
package org.bouncycastle.openpgp;
|
package org.bouncycastle.openpgp;
|
||||||
|
|
||||||
import org.bouncycastle.bcpg.MPInteger;
|
|
||||||
import org.bouncycastle.bcpg.PublicKeyAlgorithmTags;
|
import org.bouncycastle.bcpg.PublicKeyAlgorithmTags;
|
||||||
import org.bouncycastle.bcpg.SignaturePacket;
|
|
||||||
import org.bouncycastle.openpgp.operator.PGPContentSigner;
|
import org.bouncycastle.openpgp.operator.PGPContentSigner;
|
||||||
import org.bouncycastle.openpgp.operator.PGPContentSignerBuilder;
|
import org.bouncycastle.openpgp.operator.PGPContentSignerBuilder;
|
||||||
import org.bouncycastle.util.BigIntegers;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.math.BigInteger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generator for authentication signatures.
|
* Generator for authentication signatures.
|
||||||
|
@ -71,30 +67,20 @@ public class AuthenticationSignatureGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a signature object containing the current signature state.
|
* Return the signature.
|
||||||
*
|
*
|
||||||
* @return PGPSignature
|
* @return byte[]
|
||||||
* @throws PGPException
|
* @throws PGPException
|
||||||
*/
|
*/
|
||||||
public PGPSignature generate() throws PGPException {
|
public byte[] getSignature() throws PGPException {
|
||||||
MPInteger[] sigValues;
|
|
||||||
|
|
||||||
if (contentSigner.getKeyAlgorithm() == PublicKeyAlgorithmTags.RSA_SIGN
|
if (contentSigner.getKeyAlgorithm() == PublicKeyAlgorithmTags.RSA_SIGN
|
||||||
|| contentSigner.getKeyAlgorithm() == PublicKeyAlgorithmTags.RSA_GENERAL) {
|
|| contentSigner.getKeyAlgorithm() == PublicKeyAlgorithmTags.RSA_GENERAL
|
||||||
sigValues = new MPInteger[1];
|
|| contentSigner.getKeyAlgorithm() == PublicKeyAlgorithmTags.EDDSA
|
||||||
sigValues[0] = new MPInteger(new BigInteger(1, contentSigner.getSignature()));
|
|| contentSigner.getKeyAlgorithm() == PublicKeyAlgorithmTags.ECDSA
|
||||||
} else if (contentSigner.getKeyAlgorithm() == PublicKeyAlgorithmTags.EDDSA) {
|
|| contentSigner.getKeyAlgorithm() == PublicKeyAlgorithmTags.DSA) {
|
||||||
byte[] sig = contentSigner.getSignature();
|
return contentSigner.getSignature();
|
||||||
|
|
||||||
sigValues = new MPInteger[2];
|
|
||||||
|
|
||||||
sigValues[0] = new MPInteger(BigIntegers.fromUnsignedByteArray(sig, 0, 32));
|
|
||||||
sigValues[1] = new MPInteger(BigIntegers.fromUnsignedByteArray(sig, 32, 32));
|
|
||||||
} else {
|
} else {
|
||||||
sigValues = PGPUtil.dsaSigToMpi(contentSigner.getSignature());
|
throw new UnsupportedOperationException("Unsupported algorithm");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PGPSignature(new SignaturePacket(sigType, contentSigner.getKeyID(), contentSigner.getKeyAlgorithm(),
|
|
||||||
contentSigner.getHashAlgorithm(), null, null, null, sigValues));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue