question: public static byte [ ] convertASN1toXMLDSIG ( byte asn1Bytes [ ] ) throws IOException { if ( asn1Bytes . length < 8 || asn1Bytes [ 0 ] != 48 ) { throw new IOException ( "Invalid ASN.1 format of ECDSA signature" ) ; } int offset ; if ( asn1Bytes [ 1 ] > 0 ) { offset = 2 ; } else if ( asn1Bytes [ 1 ] == ( byte ) 0x81 ) { offset = 3 ; } else { throw new IOException ( "Invalid ASN.1 format of ECDSA signature" ) ; } byte rLength = asn1Bytes [ offset + 1 ] ; int i ; for ( i = rLength ; ( i > 0 ) && ( asn1Bytes [ ( offset + 2 + rLength ) - i ] == 0 ) ; i -- ) ; byte sLength = asn1Bytes [ offset + 2 + rLength + 1 ] ; int j ; for ( j = sLength ; ( j > 0 ) && ( asn1Bytes [ ( offset + 2 + rLength + 2 + sLength ) - j ] == 0 ) ; j -- ) ; int rawLen = Math . max ( i , j ) ; if ( ( asn1Bytes [ offset - 1 ] & 0xff ) != asn1Bytes . length - offset || ( asn1Bytes [ offset - 1 ] & 0xff ) != 2 + rLength + 2 + sLength || asn1Bytes [ offset ] != 2 || asn1Bytes [ offset + 2 + rLength ] != 2 ) { throw new IOException ( "Invalid ASN.1 format of ECDSA signature" ) ; } byte xmldsigBytes [ ] = new byte [ 2 * rawLen ] ; System . arraycopy ( asn1Bytes , ( offset + 2 + rLength ) - i , xmldsigBytes , rawLen - i , i ) ; System . arraycopy ( asn1Bytes , ( offset + 2 + rLength + 2 + sLength ) - j , xmldsigBytes , 2 * rawLen - j , j ) ; return xmldsigBytes ; }
target:  Converts an ASN.1 ECDSA value to a XML Signature ECDSA Value. The JAVA JCE ECDSA Signature algorithm creates ASN.1 encoded (r,s) value pairs; the XML Signature requires the core BigInteger values.