static void writeHashAndMgfHash(long seqRef, String hash, MGF1ParameterSpec mgfSpec) throws IOException {
        // Implementations are prohibited from writing the default value for any of the fields
        if (!hash.equals("SHA-1")) {
            long hashRef = 0;
            long hashParamsRef = 0;
            try {
                hashRef = NativeCrypto.asn1_write_tag(seqRef, 0);
                hashParamsRef = writeAlgorithmIdentifier(
                        hashRef, NAME_TO_OID.get(hash));
                NativeCrypto.asn1_write_null(hashParamsRef);
            } finally {
                NativeCrypto.asn1_write_flush(seqRef);
                NativeCrypto.asn1_write_free(hashParamsRef);
                NativeCrypto.asn1_write_free(hashRef);
            }
        }
        if (!mgfSpec.getDigestAlgorithm().equals("SHA-1")) {
            long mgfRef = 0;
            long mgfParamsRef = 0;
            long hashParamsRef = 0;
            try {
                mgfRef = NativeCrypto.asn1_write_tag(seqRef, 1);
                mgfParamsRef = writeAlgorithmIdentifier(mgfRef, MGF1_OID);
                hashParamsRef = writeAlgorithmIdentifier(
                        mgfParamsRef, NAME_TO_OID.get(mgfSpec.getDigestAlgorithm()));
                NativeCrypto.asn1_write_null(hashParamsRef);
            } finally {
                NativeCrypto.asn1_write_flush(seqRef);
                NativeCrypto.asn1_write_free(hashParamsRef);
                NativeCrypto.asn1_write_free(mgfParamsRef);
                NativeCrypto.asn1_write_free(mgfRef);
            }
        }
    }
AlgorithmParameters implementation for OAEP.  The only supported encoding format is ASN.1,
as specified in RFC 4055 section 4.1.
common/src/main/java/org/conscrypt/OAEPParameters.java