int fifo_underrun(void) { keyboard_clear_buffer(); clear_state(); TEST_ASSERT(press_key(0, 0, 1) == EC_SUCCESS); clear_state(); TEST_ASSERT(verify_key(0, 0, 1)); /* When FIFO under run, host command reutns last known state */ TEST_ASSERT(verify_key(-1, -1, -1)); return EC_SUCCESS; }
/* Decode and verify a key. */ int main (int argc, char *argv[]) { time_t then; char *key; int status; if (argc == 1) { printf ("usage: check_key keystring\n"); exit (0); } key = argv[1]; status = verify_key (key, &then); printf ("Expiration Date:\t%s", ctime (&then)); printf ("Activation Key: \t%s\n", key); printf ("Verify Key:\t\t%d (%s)\n", status, (status == 1) ? "OK" : "ERROR"); fprintf (stderr, "%ld", then); check_activation_key (key); return (0); }
static u16 detect_magic_keylist(u16 key) { u8 i; magic_key_info_t *p_key_info = g_magic_keylist; curn_ticks = mtos_ticks_get(); if ((curn_ticks - last_ticks) > 700) { reset_magic_keylist(); } last_ticks = curn_ticks; for (i = 0; i < MAX_MAGIC_LIST; i++) { if (p_key_info->p_key_list != NULL) { if(verify_key(p_key_info, key)) { return p_key_info->magic_key; } } p_key_info++; } return V_KEY_INVALID; }
int single_key_press(void) { keyboard_clear_buffer(); clear_state(); TEST_ASSERT(press_key(0, 0, 1) == EC_SUCCESS); TEST_ASSERT(FIFO_NOT_EMPTY()); TEST_ASSERT(press_key(0, 0, 0) == EC_SUCCESS); TEST_ASSERT(FIFO_NOT_EMPTY()); clear_state(); TEST_ASSERT(verify_key(0, 0, 1)); TEST_ASSERT(FIFO_NOT_EMPTY()); TEST_ASSERT(verify_key(0, 0, 0)); TEST_ASSERT(FIFO_EMPTY()); return EC_SUCCESS; }
krb5_error_code KRB5_CALLCONV krb5_k_make_checksum(krb5_context context, krb5_cksumtype cksumtype, krb5_key key, krb5_keyusage usage, const krb5_data *input, krb5_checksum *cksum) { const struct krb5_cksumtypes *ctp; krb5_crypto_iov iov; krb5_data cksum_data; krb5_octet *trunc; krb5_error_code ret; if (cksumtype == 0) { ret = krb5int_c_mandatory_cksumtype(context, key->keyblock.enctype, &cksumtype); if (ret != 0) return ret; } ctp = find_cksumtype(cksumtype); if (ctp == NULL) return KRB5_BAD_ENCTYPE; ret = verify_key(ctp, key); if (ret != 0) return ret; ret = alloc_data(&cksum_data, ctp->compute_size); if (ret != 0) return ret; iov.flags = KRB5_CRYPTO_TYPE_DATA; iov.data = *input; ret = ctp->checksum(ctp, key, usage, &iov, 1, &cksum_data); if (ret != 0) goto cleanup; cksum->magic = KV5M_CHECKSUM; cksum->checksum_type = cksumtype; cksum->length = ctp->output_size; cksum->contents = (krb5_octet *) cksum_data.data; cksum_data.data = NULL; if (ctp->output_size < ctp->compute_size) { trunc = realloc(cksum->contents, ctp->output_size); if (trunc != NULL) cksum->contents = trunc; } cleanup: zapfree(cksum_data.data, ctp->compute_size); return ret; }
int test_enable(void) { keyboard_clear_buffer(); clear_state(); TEST_ASSERT(set_kb_scan_enabled(0)); TEST_ASSERT(press_key(0, 0, 1) == EC_SUCCESS); TEST_ASSERT(FIFO_EMPTY()); TEST_ASSERT(set_kb_scan_enabled(1)); TEST_ASSERT(press_key(0, 0, 1) == EC_SUCCESS); TEST_ASSERT(FIFO_NOT_EMPTY()); TEST_ASSERT(verify_key(0, 0, 1)); return EC_SUCCESS; }
int test_fifo_size(void) { keyboard_clear_buffer(); clear_state(); TEST_ASSERT(set_fifo_size(1)); TEST_ASSERT(press_key(0, 0, 1) == EC_SUCCESS); TEST_ASSERT(press_key(0, 0, 0) == EC_ERROR_OVERFLOW); clear_state(); TEST_ASSERT(verify_key(0, 0, 1)); TEST_ASSERT(FIFO_EMPTY()); /* Restore FIFO size */ TEST_ASSERT(set_fifo_size(100)); return EC_SUCCESS; }
int local_authenticate(const char *id, const char *hash, const char *folder, int skew) { if(!verify_key(id, hash, folder, skew)) return PAM_SUCCESS; return PAM_AUTH_ERR; }
int verify_key(const unsigned char *ccnb, struct ccn_parsed_ContentObject *pco, int content_type){ if ( nlsr->debugging ) printf("verify key called\n"); int ret=-1; //int res; if ( contain_key_name(ccnb, pco) == 1){ struct ccn_charbuf *key_name=get_key_name(ccnb, pco); struct ccn_charbuf *key_uri = ccn_charbuf_create(); ccn_uri_append(key_uri, key_name->buf, key_name->length, 0); if ( nlsr->debugging ) printf("Key Name from Incoming Content: %s\n",ccn_charbuf_as_string(key_uri)); int key_type=get_key_type_from_key_name(key_name); if ( nlsr->debugging ) printf("Key Type: %d \n",key_type); struct ccn_charbuf *result = ccn_charbuf_create(); struct ccn_parsed_ContentObject temp_pco = {0}; int get_flags = 0; get_flags |= CCN_GET_NOKEYWAIT; int counter = 0; while(ccn_get(nlsr->ccn, key_name, NULL, 500, result, &temp_pco, NULL, get_flags) < 0 && counter < 3) counter++; int chk_verify=ccn_verify_content(nlsr->ccn,ccnb,pco); if ( chk_verify == 0 ){ if ( nlsr->debugging ) printf("Content verification Successful :)\n"); if ( counter == 3){ if ( nlsr->debugging ) printf("Could not retrieve key by name !!!\n"); } else{ if ( key_type == ROOT_KEY ){ ret=0; } else{ if ( nlsr->isStrictHierchicalKeyCheck ){ int key_name_test=check_key_name_hierarchy(ccnb, pco, key_type, content_type); if ( key_name_test == 1){ ret=verify_key(result->buf,&temp_pco,content_type); } } else{ ret=verify_key(result->buf,&temp_pco,content_type); } } } } ccn_charbuf_destroy(&result); ccn_charbuf_destroy(&key_uri); ccn_charbuf_destroy(&key_name); return ret; } return ret; }