package org.bouncycastle.jcajce.provider.asymmetric.dstu; import java.io.IOException; import java.security.SignatureException; import org.bouncycastle.asn1.ASN1OctetString; import org.bouncycastle.asn1.DEROctetString; /* loaded from: classes6.dex */ public class SignatureSpiLe extends SignatureSpi { void reverseBytes(byte[] bArr) { for (int i = 0; i < bArr.length / 2; i++) { byte b = bArr[i]; bArr[i] = bArr[(bArr.length - 1) - i]; bArr[(bArr.length - 1) - i] = b; } } /* JADX INFO: Access modifiers changed from: protected */ @Override // org.bouncycastle.jcajce.provider.asymmetric.dstu.SignatureSpi, java.security.SignatureSpi public boolean engineVerify(byte[] bArr) throws SignatureException { try { byte[] octets = ((ASN1OctetString) ASN1OctetString.fromByteArray(bArr)).getOctets(); reverseBytes(octets); try { return super.engineVerify(new DEROctetString(octets).getEncoded()); } catch (SignatureException e) { throw e; } catch (Exception e2) { throw new SignatureException(e2.toString()); } } catch (IOException unused) { throw new SignatureException("error decoding signature bytes."); } } /* JADX INFO: Access modifiers changed from: protected */ @Override // org.bouncycastle.jcajce.provider.asymmetric.dstu.SignatureSpi, java.security.SignatureSpi public byte[] engineSign() throws SignatureException { byte[] octets = ASN1OctetString.getInstance(super.engineSign()).getOctets(); reverseBytes(octets); try { return new DEROctetString(octets).getEncoded(); } catch (Exception e) { throw new SignatureException(e.toString()); } } }