Пример #1
0
void dump_wireshark(char *c_hex, BIGNUM *mt)
{
    // Now PCKS#1 v1.5 unpad the message
    unsigned char bin[256] = {0};
    BN_bn2bin(mt, bin + 256 - BN_num_bytes(mt));
    MY_ASSERT(bin[0] == 0, "decrypted message is not properly padded");
    MY_ASSERT(bin[1] == 2, "decrypted message is not properly padded");
    int i = 2;
    while(bin[i])
    {
        i++;
        MY_ASSERT(i < 256, "decrypted message is not properly padded");
    }
    i++;

    // We can now print the unpadded message
    // (in Wireshark format)
    printf("RSA ");
    printf("%.16s ", c_hex);
    print_hexbuf(&bin[i], 256-i);
    printf("\n");
}
Пример #2
0
int upcall_parse(
    IN unsigned char *buffer,
    IN uint32_t length,
    OUT nfs41_upcall *upcall)
{
    int status;
    const nfs41_upcall_op *op;
    DWORD version;

    ZeroMemory(upcall, sizeof(nfs41_upcall));
    if (!length) {
        eprintf("empty upcall\n");
        upcall->status = status = 102;
        goto out;
    }

    dprintf(2, "received %d bytes upcall data: processing upcall\n", length);
    print_hexbuf(4, (unsigned char *)"upcall buffer: ", buffer, length);

    /* parse common elements */
    status = safe_read(&buffer, &length, &version, sizeof(uint32_t));
    if (status) goto out;
    status = safe_read(&buffer, &length, &upcall->xid, sizeof(uint64_t));
    if (status) goto out;
    status = safe_read(&buffer, &length, &upcall->opcode, sizeof(uint32_t));
    if (status) goto out;
    status = safe_read(&buffer, &length, &upcall->root_ref, sizeof(HANDLE));
    if (status) goto out;
    status = safe_read(&buffer, &length, &upcall->state_ref, sizeof(HANDLE));
    if (status) goto out;

    dprintf(2, "time=%ld version=%d xid=%d opcode=%s session=0x%x open_state=0x%x\n", 
        time(NULL), version, upcall->xid, opcode2string(upcall->opcode), upcall->root_ref, 
        upcall->state_ref);
    if (version != NFS41D_VERSION) {
        eprintf("received version %d expecting version %d\n", version, NFS41D_VERSION);
        upcall->status = status = NFSD_VERSION_MISMATCH;
        goto out;
    }
    if (upcall->opcode >= g_upcall_op_table_size) {
        status = ERROR_NOT_SUPPORTED;
        eprintf("unrecognized upcall opcode %d!\n", upcall->opcode);
        goto out;
    }
    if (upcall->root_ref != INVALID_HANDLE_VALUE)
        nfs41_root_ref(upcall->root_ref);
    if (upcall->state_ref != INVALID_HANDLE_VALUE)
        nfs41_open_state_ref(upcall->state_ref);

    /* parse the operation's arguments */
    op = g_upcall_op_table[upcall->opcode];
    if (op && op->parse) {
        status = op->parse(buffer, length, upcall);
        if (status) {
            eprintf("parsing of upcall '%s' failed with %d.\n",
                opcode2string(upcall->opcode), status);
            goto out;
        }
    }
out:
    return status;
}