Esempio n. 1
1
void des::decrypt(char const* key, core::vector<byte> const& in, core::string& out)
{
    DES_cblock key_block;
    DES_key_schedule schedule;
    DES_string_to_key(key, &key_block);
    DES_set_key_checked(&key_block, &schedule);

    char* buf = (char*)malloc(in.size());

    core::vector<byte>::const_iterator iter = in.begin();
    DES_cblock* output = (DES_cblock*)buf;

    DES_cblock input;
    while (iter != in.end())
    {
        usize sz = in.end() - iter;
        if (sz >= 8)
            sz = 8;
        else
            memset(input, 0, sizeof(DES_cblock));
        memcpy(input, &*iter, sz);
        DES_ecb_encrypt(&input, output, &schedule, DES_DECRYPT);
        iter += sz;
        output += 1;
    }

    out = buf;

    free(buf);
}
Esempio n. 2
0
void clear_buffers()
{
    if (d_owner->need_release && d_owner->queue)
    {
        for (core::vector<AudioQueueBufferRef>::iterator each = buffers.begin();
                each != buffers.end();
                ++each)
        {
            if (*each != NULL)
            {
                AudioQueueFreeBuffer(d_owner->queue, *each);
                *each = NULL;
            }
        }
    }
}
Esempio n. 3
0
void create_buffers()
{
    clear_buffers();

    usize sz = calc_buffer_size();

    OSStatus sta;
    for (core::vector<AudioQueueBufferRef>::iterator each = buffers.begin();
            each != buffers.end();
            ++each)
    {
        if ((sta = AudioQueueAllocateBuffer(d_owner->queue, sz, &*each)))
        {
            trace_fmt("failed to allocate audio buffer, %.4s", (char*)&sta);
        }
    }
}