本文整理汇总了C++中set_key函数的典型用法代码示例。如果您正苦于以下问题:C++ set_key函数的具体用法?C++ set_key怎么用?C++ set_key使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_key函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool aes_ctr_encrypter::set_key(const aes_256_key_t& key)
{
if (set_key(EVP_aes_256_ctr(), key.key, key.iv) == false)
{
return false;
}
return true;
}
示例2: calc_size_n_pad
void AES::do_aes_encrypt(byte *plain,int size_p,byte *cipher,byte *key, int bits)
{
calc_size_n_pad(size_p);
byte plain_p[get_size()];
padPlaintext(plain,plain_p);
int blocks = get_size() / N_BLOCK;
set_key (key, bits) ;
cbc_encrypt (plain_p, cipher, blocks);
}
示例3: GOOGLE_CHECK_NE
void LanguageData_Language::MergeFrom(const LanguageData_Language& from) {
GOOGLE_CHECK_NE(&from, this);
statement_.MergeFrom(from.statement_);
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (from.has_key()) {
set_key(from.key());
}
}
}
示例4: set_802_11_add_wep
u8 set_802_11_add_wep(_adapter* padapter, NDIS_802_11_WEP *wep)
{
u8 bdefaultkey;
u8 btransmitkey;
sint keyid;
struct security_priv *psecuritypriv = &padapter->securitypriv;
u8 ret = _SUCCESS;
_func_enter_;
bdefaultkey = (wep->KeyIndex & 0x40000000) > 0 ? _FALSE : _TRUE; //for ???
btransmitkey = (wep->KeyIndex & 0x80000000) > 0 ? _TRUE : _FALSE; //for ???
keyid = wep->KeyIndex & 0x3fffffff;
if (keyid >= WEP_KEYS) {
RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("MgntActSet_802_11_ADD_WEP: keyid>4 FAIL!\n"));
ret = _FALSE;
goto exit;
}
switch (wep->KeyLength)
{
case 5:
psecuritypriv->dot11PrivacyAlgrthm = _WEP40_;
RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("MgntActSet_802_11_ADD_WEP:wep->KeyLength=5\n"));
break;
case 13:
psecuritypriv->dot11PrivacyAlgrthm = _WEP104_;
RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("MgntActSet_802_11_ADD_WEP:wep->KeyLength=13\n"));
break;
default:
psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("MgntActSet_802_11_ADD_WEP:wep->KeyLength!=5 or 13\n"));
break;
}
RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("MgntActSet_802_11_ADD_WEP:befor memcpy, wep->KeyLength=0x%x wep->KeyIndex=0x%x keyid =%x\n",wep->KeyLength,wep->KeyIndex,keyid));
_memcpy(psecuritypriv->dot11DefKey[keyid].skey, &wep->KeyMaterial, wep->KeyLength);
psecuritypriv->dot11DefKeylen[keyid] = wep->KeyLength;
psecuritypriv->dot11PrivacyKeyIndex = keyid;
RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("MgntActSet_802_11_ADD_WEP:security key material: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
psecuritypriv->dot11DefKey[keyid].skey[0],psecuritypriv->dot11DefKey[keyid].skey[1],psecuritypriv->dot11DefKey[keyid].skey[2],
psecuritypriv->dot11DefKey[keyid].skey[3],psecuritypriv->dot11DefKey[keyid].skey[4],psecuritypriv->dot11DefKey[keyid].skey[5],
psecuritypriv->dot11DefKey[keyid].skey[6],psecuritypriv->dot11DefKey[keyid].skey[7],psecuritypriv->dot11DefKey[keyid].skey[8],
psecuritypriv->dot11DefKey[keyid].skey[9],psecuritypriv->dot11DefKey[keyid].skey[10],psecuritypriv->dot11DefKey[keyid].skey[11],
psecuritypriv->dot11DefKey[keyid].skey[12]));
if (set_key(padapter, psecuritypriv, keyid) == _FAIL)
ret = _FALSE;
exit:
_func_exit_;
return ret;
}
示例5: LoadConfig
void LoadConfig()
{
FILE *f;
char str[256];
bool have_user_setting = false;
if (!conf)
conf = new PADconf;
conf->init();
const std::string iniFile(s_strIniPath + "OnePAD.ini");
f = fopen(iniFile.c_str(), "r");
if (f == NULL)
{
printf("OnePAD: failed to load ini %s\n", iniFile.c_str());
SaveConfig(); //save and return
return;
}
u32 value;
if (fscanf(f, "log = %d\n", &value) == 0) return;
conf->log = value;
if (fscanf(f, "options = %d\n", &value) == 0) return;
conf->options = value;
if (fscanf(f, "mouse_sensibility = %d\n", &value) == 0) return;
conf->sensibility = value;
if (fscanf(f, "joy_pad_map = %d\n", &value) == 0) return;
conf->joyid_map = value;
if (fscanf(f, "ff_intensity = %d\n", &value) == 0) return;
conf->ff_intensity = value;
for (int pad = 0; pad < 2; pad++)
{
for (int key = 0; key < MAX_KEYS; key++)
{
sprintf(str, "[%d][%d] = 0x%%x\n", pad, key);
u32 temp = 0;
if (fscanf(f, str, &temp) == 0) temp = 0;
set_key(pad, key, temp);
if (temp && pad == 0) have_user_setting = true;
}
}
u32 pad;
u32 keysym;
u32 index;
while( fscanf(f, "PAD %d:KEYSYM 0x%x = %d\n", &pad, &keysym, &index) != EOF ) {
set_keyboad_key(pad, keysym, index);
if(pad == 0) have_user_setting = true;
}
fclose(f);
if (!have_user_setting) DefaultKeyboardValues();
}
示例6: switch
void Client::on_input_event(const InputData& input) {
if (!are_options_visible()) {
switch (input.data_type) {
case InputData::InputDataTypeKeyDown:
set_key(MappedKey::DeviceKeyboard, input.keycode);
/* escape fallback */
if (input.key_type == InputData::InputKeyTypeEscape) {
if (!input.key_repeat) {
show_options_menu();
}
}
break;
case InputData::InputDataTypeKeyUp:
reset_key(MappedKey::DeviceKeyboard, input.keycode);
break;
case InputData::InputDataTypeJoyButtonDown:
set_key(MappedKey::DeviceJoyButton, input.param1);
break;
case InputData::InputDataTypeJoyButtonUp:
reset_key(MappedKey::DeviceJoyButton, input.param1);
break;
case InputData::InputDataTypeJoyMotion:
{
joyaxis_t axis = static_cast<joyaxis_t>(input.param1);
if (me) {
if (!get_stack_count()) {
me->state.client_server_state.jaxis = axis;
} else {
me->state.client_server_state.jaxis = 0;
}
}
break;
}
default:
break;
}
}
}
示例7: draw_ring
void draw_ring(struct razer_keys *keys,struct razer_pos *pos,struct razer_rgb *color)
{
set_key(keys,pos->x+1, pos->y,color);
set_key(keys,pos->x-1, pos->y,color);
if(pos->y==4 || pos->y==1)
{
set_key(keys,pos->x-1, pos->y-1,color);
set_key(keys,pos->x, pos->y-1,color);
set_key(keys,pos->x-1, pos->y+1,color);
set_key(keys,pos->x, pos->y+1,color);
}
else
{
set_key(keys,pos->x, pos->y-1,color);
set_key(keys,pos->x+1, pos->y-1,color);
set_key(keys,pos->x, pos->y+1,color);
set_key(keys,pos->x+1, pos->y+1,color);
}
}
示例8: find_best_workgroup
static void find_best_workgroup()
{
cl_event myEvent;
cl_ulong startTime, endTime, kernelExecTimeNs = CL_ULONG_MAX;
size_t my_work_group = 1;
cl_int ret_code;
int i;
size_t max_group_size;
clGetDeviceInfo(devices[gpu_id], CL_DEVICE_MAX_WORK_GROUP_SIZE,
sizeof(max_group_size), &max_group_size, NULL);
cl_command_queue queue_prof =
clCreateCommandQueue(context[gpu_id], devices[gpu_id],
CL_QUEUE_PROFILING_ENABLE,
&ret_code);
//printf("Max Group Work Size %d\n",(int)max_group_size);
local_work_size = 1;
/// Set keys
char *pass = "aaaaaaaa";
for (i = 0; i < KEYS_PER_CRYPT; i++) {
set_key(pass, i);
}
/// Copy data to GPU
HANDLE_CLERROR(clEnqueueWriteBuffer
(queue_prof, mem_in, CL_FALSE, 0, insize, inbuffer, 0, NULL, NULL),
"Copy memin");
HANDLE_CLERROR(clEnqueueWriteBuffer(queue_prof, mem_salt, CL_FALSE, 0,
saltsize, &host_salt, 0, NULL, NULL), "Copy memsalt");
/// Find minimum time
for (my_work_group = 1; (int) my_work_group <= (int) max_group_size;
my_work_group *= 2) {
size_t localworksize = my_work_group;
HANDLE_CLERROR(clEnqueueNDRangeKernel
(queue_prof, crypt_kernel, 1, NULL, &global_work_size,
&localworksize, 0, NULL, &myEvent), "Set ND range");
HANDLE_CLERROR(clFinish(queue_prof), "clFinish error");
clGetEventProfilingInfo(myEvent, CL_PROFILING_COMMAND_SUBMIT,
sizeof(cl_ulong), &startTime, NULL);
clGetEventProfilingInfo(myEvent, CL_PROFILING_COMMAND_END,
sizeof(cl_ulong), &endTime, NULL);
if ((endTime - startTime) < kernelExecTimeNs) {
kernelExecTimeNs = endTime - startTime;
local_work_size = my_work_group;
}
//printf("%d time=%lld\n",(int) my_work_group, endTime-startTime);
}
//printf("Optimal Group work Size = %d\n",(int)local_work_size);
clReleaseCommandQueue(queue_prof);
}
示例9: testDES
void testDES()
{
char t[100]="11111111";
int i;
set_key(t);
scanf("%s",t);
des_encrypt(t,t);
printf("密文长度为%d %s\n",strlen(t),t);
des_decrypt(t,t);
printf("明文长度为%d %s\n",strlen(t),t);
}
示例10: str
result_t Stats::set_key(int n, v8::Local<v8::Value> key)
{
v8::String::Utf8Value str(key);
const char *p = *str;
if (p == NULL)
return CHECK_ERROR(CALL_E_INVALIDARG);
set_key(n, p);
return 0;
}
示例11: set_key
void Preferences::copy(const Preferences& preferences) {
for (size_t i = 0; i < KEY_COUNT; ++i) {
set_key(i, preferences.key(i));
}
set_play_idle_music(preferences.play_idle_music());
set_play_music_in_game(preferences.play_music_in_game());
set_speech_on(preferences.speech_on());
set_volume(preferences.volume());
set_screen_size(preferences.screen_size());
set_scenario_identifier(preferences.scenario_identifier());
}
示例12: EAX_Base
/*
* EAX_Decryption Constructor
*/
EAX_Decryption::EAX_Decryption(BlockCipher* ciph,
const SymmetricKey& key,
const InitializationVector& iv,
size_t tag_size) :
EAX_Base(ciph, tag_size)
{
set_key(key);
set_iv(iv);
queue.resize(2*TAG_SIZE + DEFAULT_BUFFERSIZE);
queue_start = queue_end = 0;
}
示例13: remove_selected
void remove_selected()
{
int key, pad, keysym;
if (get_selected(pad, key, keysym))
{
if (keysym)
conf->keysym_map[pad].erase(keysym);
else
set_key(pad, key, 0);
update();
}
}
示例14: set_key
void Client::set_key(MappedKey::Device dev, int param) {
set_key(dev, param, binding.left, PlayerKeyStateLeft);
set_key(dev, param, binding.right, PlayerKeyStateRight);
set_key(dev, param, binding.up, PlayerKeyStateUp);
set_key(dev, param, binding.down, PlayerKeyStateDown);
set_key(dev, param, binding.jump, PlayerKeyStateJump);
set_key(dev, param, binding.fire, PlayerKeyStateFire);
set_key(dev, param, binding.drop1, PlayerKeyStateDrop1);
set_key(dev, param, binding.drop2, PlayerKeyStateDrop2);
set_key(dev, param, binding.drop3, PlayerKeyStateDrop3);
if (binding.chat.device == dev && binding.chat.param == param) {
if (!get_stack_count()) {
subsystem.clear_input_buffer();
int vw = subsystem.get_view_width();
int vh = subsystem.get_view_height();
int ww = 350;
int wh = 30;
GuiWindow *window = push_window(1, 1, ww, wh, "Enter Message");
window->set_on_keydown(static_window_keydown, this);
window->set_on_joybuttondown(static_window_joybutton_down, this);
ww = window->get_client_width();
chat_textbox = create_textbox(window, Spc, Spc, ww - 2 * Spc, "");
window->set_height(window->get_height() - window->get_client_height() + 2 * Spc + chat_textbox->get_height());
window->set_x(vw / 2 - window->get_client_width() / 2);
window->set_y(vh / 2 - window->get_client_height() / 2);
chat_textbox->set_focus();
if (me) {
me->state.client_server_state.key_states = 0;
}
}
}
if (binding.stats.device == dev && binding.stats.param == param) {
if (!get_stack_count()) {
if (tournament) {
tournament->show_stats(true);
}
}
}
if (binding.escape.device == dev && binding.escape.param == param) {
show_options_menu();
}
}
示例15: set_key
/*
* XTS_Decryption constructor
*/
XTS_Decryption::XTS_Decryption(BlockCipher* ciph,
const SymmetricKey& key,
const InitializationVector& iv)
{
cipher = ciph;
cipher2 = ciph->clone();
tweak.create(cipher->BLOCK_SIZE);
buffer.create(2 * cipher->BLOCK_SIZE);
position = 0;
set_key(key);
set_iv(iv);
}