public static byte[] ecdsaIeee2Der(byte[] ieee) throws GeneralSecurityException {
    if (ieee.length % 2 != 0 || ieee.length == 0 || ieee.length > 132) {
      throw new GeneralSecurityException("Invalid IEEE_P1363 encoding");
    }
    byte[] r = toMinimalSignedNumber(Arrays.copyOf(ieee, ieee.length / 2));
    byte[] s = toMinimalSignedNumber(Arrays.copyOfRange(ieee, ieee.length / 2, ieee.length));

    int offset = 0;
    int length = 1 + 1 + r.length + 1 + 1 + s.length;
    byte[] der;
    if (length >= 128) {
      der = new byte[length + 3];
      der[offset++] = (byte) 0x30;
      der[offset++] = (byte) (0x80 + 0x01);
      der[offset++] = (byte) length;
    } else {
      der = new byte[length + 2];
      der[offset++] = (byte) 0x30;
      der[offset++] = (byte) length;
    }
    der[offset++] = (byte) 0x02;
    der[offset++] = (byte) r.length;
    System.arraycopy(r, 0, der, offset, r.length);
    offset += r.length;
    der[offset++] = (byte) 0x02;
    der[offset++] = (byte) s.length;
    System.arraycopy(s, 0, der, offset, s.length);
    return der;
  }
Transforms ECDSA IEEE_P1363 signature encoding to DER 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 ieee ECDSA's signature in IEEE_P1363 format.
@return ECDSA's signature in DER format.
@throws GeneralSecurityException if ieee's length is zero, greater than 132-byte (corresponding
    to NIST P521) or not divisible by 2.
java_src/src/main/java/com/google/crypto/tink/subtle/EllipticCurves.java