public static byte[] ecdsaDer2Ieee(byte[] der, int ieeeLength) throws GeneralSecurityException {
    if (!isValidDerEncoding(der)) {
      throw new GeneralSecurityException("Invalid DER encoding");
    }
    byte[] ieee = new byte[ieeeLength];
    int length = der[1] & 0xff;
    int offset = 1 /* 0x30 */ + 1 /* totalLength */;
    if (length >= 128) {
      offset++; // Long form length
    }
    offset++; // 0x02
    int rLength = der[offset++];
    int extraZero = 0;
    if (der[offset] == 0) {
      extraZero = 1;
    }
    System.arraycopy(
        der, offset + extraZero, ieee, ieeeLength / 2 - rLength + extraZero, rLength - extraZero);
    offset += rLength /* r byte array */ + 1 /* 0x02 */;
    int sLength = der[offset++];
    extraZero = 0;
    if (der[offset] == 0) {
      extraZero = 1;
    }
    System.arraycopy(
        der, offset + extraZero, ieee, ieeeLength - sLength + extraZero, sLength - extraZero);
    return ieee;
  }
Transforms ECDSA DER signature encoding to IEEE_P1363 encoding.

<p>The IEEE_P1363 signature's format is r || s, where r and s are zero-padded and have the same
size in bytes as the order of the curve. For example, for NIST P-256 curve, r and s are
zero-padded to 32 bytes.

<p>The DER signature is encoded using ASN.1 (https://tools.ietf.org/html/rfc5480#appendix-A):
ECDSA-Sig-Value :: = SEQUENCE { r INTEGER, s INTEGER }. In particular, the encoding is: 0x30 ||
totalLength || 0x02 || r's length || r || 0x02 || s's length || s.

@param der ECDSA's signature in DER encoding.
@param ieeeLength length of ECDSA signature's in IEEE_P1363's format which equals to 2 * (size
    of elliptic curve's field in bytes).
@return ECDSA's signature in IEEE_P1363 format.
@throws GeneralSecurityException if the signature is not valid DER encoding.
java_src/src/main/java/com/google/crypto/tink/subtle/EllipticCurves.java