private static byte[] buildOid(String hex)
    {
        byte[] oid = new byte[SIZE];

        for (int i = 0; i < HEX_SIZE; ++i)
        {
            char c = hex.charAt(i);

            if (c >= '0' && c <= '9')
            {
                c -= '0';
            }
            else if (c >= 'a' && c <= 'f')
            {
                c -= 'a' - 10;
            }
            else if (c >= 'A' && c <= 'F')
            {
                c -= 'A' - 10;
            }
            else
            {
                throw new IllegalArgumentException(String.format("Invalid character in sha1: {0}", c));
            }

            oid[i / 2] |= (i % 2) == 0 ? (byte) (c << 4) : (byte) c;
        }

        return oid;
    }