private byte[] encryptUpperTransportPDU(@NonNull final AccessMessage message) {
        final byte[] accessPDU = message.getAccessPdu();
        final int akf = message.getAkf();
        final int aszmic = message.getAszmic(); // upper transport layer will always have the aszmic as 0 because the mic is always 32bit

        final byte[] sequenceNumber = message.getSequenceNumber();
        final int src = message.getSrc();
        final int dst = message.getDst();
        final byte[] ivIndex = message.getIvIndex();
        final byte[] key;

        byte[] nonce;
        if (akf == APPLICATION_KEY_IDENTIFIER) {
            key = message.getDeviceKey();
            nonce = createDeviceNonce(aszmic, sequenceNumber, src, dst, ivIndex);
            MeshLogger.verbose(TAG, "Device nonce: " + MeshParserUtils.bytesToHex(nonce, false));
        } else {
            key = message.getApplicationKey().getKey();
            nonce = createApplicationNonce(aszmic, sequenceNumber, src, dst, ivIndex);
            MeshLogger.verbose(TAG, "Application nonce: " + MeshParserUtils.bytesToHex(nonce, false));
        }

        int transMicLength;
        final int encryptedPduLength = accessPDU.length + MINIMUM_TRANSMIC_LENGTH;

        if (encryptedPduLength <= MAX_UNSEGMENTED_ACCESS_PAYLOAD_LENGTH) {
            transMicLength = SecureUtils.getTransMicLength(message.getCtl());
        } else {
            transMicLength = SecureUtils.getTransMicLength(message.getAszmic());
        }
        if (MeshAddress.isValidVirtualAddress(dst)) {
            return SecureUtils.encryptCCM(accessPDU, key, nonce, MeshParserUtils.uuidToBytes(message.getLabel()), transMicLength);
        } else {
            return SecureUtils.encryptCCM(accessPDU, key, nonce, transMicLength);
        }
    }
Encrypts upper transport pdu

@param message access message object containing the upper transport pdu
@return encrypted upper transport pdu
mesh/src/main/java/no/nordicsemi/android/mesh/transport/UpperTransportLayer.java