Example #1
0
RC4EAPOL::RC4EAPOL(const uint8_t* buffer, uint32_t total_sz) 
: EAPOL(buffer, total_sz) {
    InputMemoryStream stream(buffer, total_sz);
    stream.skip(sizeof(eapol_header));
    stream.read(header_);
    if (stream.size() >= key_length()) {
        stream.read(key_, key_length());
        if (stream) {
            inner_pdu(new RawPDU(stream.pointer(), stream.size()));
        }
    }
}
Example #2
0
/* make a new row by copying the key fields from r */
Row
RowGetKey(Row *r)
{
	Row row = {0,0,0};
	size_t nb = key_length(r);
	size_t n = g_row_key_n;

	char *d = pg_malloc(nb);

	size_t i = 0;
	char *out_iter = d;

	row.ptr = d;
	row.fields = pg_malloc(n * sizeof(Field));
	row.n = n;

	TermAssert(RowSize(r) > g_row_key_n);

	for (i = 0; i < n; ++i)
	{
		size_t col = g_row_key[i];
		char *tok = out_iter;

		memcpy(out_iter, r->fields[col].data, r->fields[col].n);
		out_iter += r->fields[col].n;
		*out_iter++ = '\0';

		row.fields[i].data = tok;
		row.fields[i].n = r->fields[col].n;
	}

	return row;
}
Example #3
0
RC4EAPOL::RC4EAPOL(const uint8_t *buffer, uint32_t total_sz) 
: EAPOL(buffer, total_sz)
{
    buffer += sizeof(eapolhdr);
    total_sz -= sizeof(eapolhdr);
    if(total_sz < sizeof(_header))
        throw malformed_packet();
    std::memcpy(&_header, buffer, sizeof(_header));
    buffer += sizeof(_header);
    total_sz -= sizeof(_header);
    if(total_sz == key_length())
        _key.assign(buffer, buffer + total_sz);
}
Example #4
0
size_t
max_crypt_size(const context& d) {
    // padding / header data (11 bytes for PKCS#1 v1.5 padding).
    if (type_of(d) == pk_t::rsa)
        return key_length(d) - 11;

#if defined(MBEDTLS_ECDSA_C)
    else if (can_do(d, pk_t::ecdsa))
        return (size_t)MBEDTLS_ECDSA_MAX_LEN;
#endif

    throw exceptions::support_error{};
}
Example #5
0
File: key.c Project: dw/acid
/**
 * Fetch a slice of the Key.
 */
static PyObject *
key_subscript(Key *self, PyObject *key)
{
    if(PySlice_Check(key)) {
        // TODO: make this more efficient
        PyObject *tup = PySequence_Tuple((PyObject *) self);
        PyObject *slice = NULL;
        PyObject *newkey = NULL;
        if(tup) {
            PyMappingMethods *funcs = tup->ob_type->tp_as_mapping;
            slice = funcs->mp_subscript((PyObject *) tup, key);
            Py_DECREF(tup);
        }
        if(slice) {
            newkey = key_new(&KeyType, slice, NULL);
            Py_DECREF(slice);
        }
        return newkey;
    } else {
        // Fetch the `i`th item from the Key.
        Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_OverflowError);
        if(i == -1 && PyErr_Occurred()) {
            return NULL;
        }
        struct reader rdr;
        rdr.p = Key_DATA(self);
        rdr.e = Key_SIZE(self) + rdr.p;
        int eof = rdr.p == rdr.e;

        if(i < 0) {
            // TODO: make this more efficient
            Py_ssize_t len = key_length(self);
            i += len;
            eof |= i < 0;
        }
        while(i-- && !eof) {
            if(acid_skip_element(&rdr, &eof)) {
                return NULL;
            }
        }
        if(eof) {
            PyErr_SetString(PyExc_IndexError, "Key index out of range");
            return NULL;
        }
        return acid_read_element(&rdr);
    }
}
Example #6
0
size_t EC_PublicKey::estimated_strength() const
   {
   return ecp_work_factor(key_length());
   }
Example #7
0
size_t PKCS11_EC_PrivateKey::estimated_strength() const
   {
   return ecp_work_factor(key_length());
   }