Ejemplo n.º 1
0
static
void MichaelGetMIC( struct michel_mic_t *Mic, uint8_t *dst )
{
	uint8_t *data = Mic->M;
	switch (Mic->nBytesInM) {
	case 0:
		Mic->L ^= 0x5a;
		break;
	case 1:
		Mic->L ^= data[0] | 0x5a00;
		break;
	case 2:
		Mic->L ^= data[0] | (data[1] << 8) | 0x5a0000;
		break;
	case 3:
		Mic->L ^= data[0] | (data[1] << 8) | (data[2] << 16) |
			0x5a000000;
		break;
	}
	MichaelBlockFunction(Mic->L, Mic->R);
	MichaelBlockFunction(Mic->L, Mic->R);
	// The appendByte function has already computed the result.
	putUInt32( dst, 0, Mic->L );
	putUInt32( dst, 4, Mic->R );

	// Reset to the empty message.
	MichaelClear(Mic);
}
Ejemplo n.º 2
0
void MtpDataPacket::putAUInt32(const UInt32List* list) {
    if (!list) {
        putEmptyArray();
    } else {
        size_t size = list->size();
        putUInt32(size);
        for (size_t i = 0; i < size; i++)
            putUInt32((*list)[i]);
    }
}
Ejemplo n.º 3
0
void NetMessage::putString(const std::string &value) {
	unsigned strSize = value.size();
	unsigned i;
	putUInt32(strSize);
	for (i = 0; i < strSize; i++) {
		putUInt8(value.c_str()[i]);
	}
}
    // write our buffer to the given endpoint (host mode)
int MtpRequestPacket::write(struct usb_request *request)
{
    putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize);
    putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_COMMAND);
    request->buffer = mBuffer;
    request->buffer_length = mPacketSize;
    return transfer(request);
}
Ejemplo n.º 5
0
void MtpPacket::setParameter(int index, uint32_t value) {
    if (index < 1 || index > 5) {
        ALOGE("index %d out of range in MtpPacket::setParameter", index);
        return;
    }
    int offset = MTP_CONTAINER_PARAMETER_OFFSET + (index - 1) * sizeof(uint32_t);
    if (mPacketSize < offset + sizeof(uint32_t))
        mPacketSize = offset + sizeof(uint32_t);
    putUInt32(offset, value);
}
int MtpEventPacket::write(int fd) {
    struct mtp_event    event;

    putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize);
    putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_EVENT);

    event.data = mBuffer;
    event.length = mPacketSize;
    int ret = ::ioctl(fd, MTP_SEND_EVENT, (unsigned long)&event);
    return (ret < 0 ? ret : 0);
}
Ejemplo n.º 7
0
int MtpEventPacket::write(int fd) {
    struct mtp_event    event;

    putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize);
    putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_EVENT);

    event.data = mBuffer;
    event.length = mPacketSize;
    int ret = ::ioctl(fd, MTP_SEND_EVENT, (unsigned long)&event);

    //Added for USB Develpment debug, more log for more debuging help
    sxlog_printf(ANDROID_LOG_VERBOSE, "MtpEventPacket",
                "%s: mBuffer = %p, mPacketSize = 0x%d, &event = %p \n", __func__, mBuffer, mPacketSize, (&event));
    //Added for USB Develpment debug, more log for more debuging help

    return (ret < 0 ? ret : 0);
}
Ejemplo n.º 8
0
void MtpPacket::setTransactionID(MtpTransactionID id) {
    putUInt32(MTP_CONTAINER_TRANSACTION_ID_OFFSET, id);
}
int MtpResponsePacket::write(int fd) {
    putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize);
    putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_RESPONSE);
    int ret = ::write(fd, mBuffer, mPacketSize);
    return (ret < 0 ? ret : 0);
}
Ejemplo n.º 10
0
void MtpDataPacket::putAUInt64(const uint64_t* values, int count) {
    putUInt32(count);
    for (int i = 0; i < count; i++)
        putUInt64(*values++);
}
Ejemplo n.º 11
0
void MtpDataPacket::putAInt32(const int32_t* values, int count) {
    putUInt32(count);
    for (int i = 0; i < count; i++)
        putInt32(*values++);
}
Ejemplo n.º 12
0
void MtpDataPacket::putAUInt16(const UInt16List* values) {
    size_t count = (values ? values->size() : 0);
    putUInt32(count);
    for (size_t i = 0; i < count; i++)
        putUInt16((*values)[i]);
}
Ejemplo n.º 13
0
void MtpDataPacket::putUInt128(const uint128_t& value) {
    putUInt32(value[0]);
    putUInt32(value[1]);
    putUInt32(value[2]);
    putUInt32(value[3]);
}