Пример #1
0
int add_splinekey(PARAM_CONTROL *pc,SPLINE_KEY **nsk,int x,int y)
{
	int result=FALSE;
	EnterCriticalSection(&mutex);
	if(pc){
		if(pc->control.type==CSPLINE){
			SPLINE_CONTROL *sc=pc->control.data;
			if(sc){
				int i=sc->selected;
				ANIMATE_DATA *a=sc->anim;
				if(a){
					SPLINE_KEY *sk=0;
					alloc_key(&sk);
					if(sk){
						SPLINE_KEY_CONTROL *skc=0;
						add_splinekey_control(sc,sk,&skc);
						if(skc){
							skc->x=x;
							skc->y=y;
							init_skc_pos(sc,skc);
						}
						insert_keylist(&a[i],sk);
						if(nsk)
							*nsk=sk;

						result=TRUE;
					}
				}
			}
		}
	}
	LeaveCriticalSection(&mutex);
	return result;
}
Пример #2
0
static int
add_key (vector vec, char * str, unsigned long code, int has_param)
{
	struct key * kw;

	kw = alloc_key();

	if (!kw)
		return 1;

	kw->code = code;
	kw->has_param = has_param;
	kw->str = STRDUP(str);

	if (!kw->str)
		goto out;

	if (!vector_alloc_slot(vec))
		goto out1;

	vector_set_slot(vec, kw);

	return 0;

out1:
	FREE(kw->str);
out:
	FREE(kw);
	return 1;
}
Пример #3
0
CAMLprim value xmlsecml_xmlSecKeyReadBinaryFile(value camlKeyDataId, value camlFileName)
{
  CAMLparam2(camlKeyDataId, camlFileName);
  xmlSecKeyDataId keyDataId = xmlSecKeyDataAesId;
  char *filename = String_val(camlFileName);
  xmlSecKeyPtr key = xmlSecKeyReadBinaryFile(keyDataId, filename);
  assert(key!=NULL);
  CAMLreturn(alloc_key(key));
}
Пример #4
0
/* the wrapper functions for blowfish */
static int blowfish_set_key(struct crypto_struct *cipher, void *key){
  if (cipher->key == NULL) {
    if (alloc_key(cipher) < 0) {
      return -1;
    }
    BF_set_key(cipher->key, 16, key);
  }

  return 0;
}
Пример #5
0
/* the wrapper functions for blowfish */
static int blowfish_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV){
  if (cipher->key == NULL) {
    if (alloc_key(cipher) < 0) {
      return -1;
    }
    BF_set_key(cipher->key, 16, key);
  }
  cipher->IV = IV;
  return 0;
}
Пример #6
0
static int des1_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV){
  if(!cipher->key){
    if (alloc_key(cipher) < 0) {
      return -1;
    }
    DES_set_odd_parity(key);
    DES_set_key_unchecked(key,cipher->key);
  }
  cipher->IV=IV;
  return 0;
}
Пример #7
0
static int aes_set_decrypt_key(struct crypto_struct *cipher, void *key) {
  if (cipher->key == NULL) {
    if (alloc_key(cipher) < 0) {
      return -1;
    }
    if (AES_set_decrypt_key(key,cipher->keysize,cipher->key) < 0) {
      SAFE_FREE(cipher->key);
      return -1;
    }
  }

  return 0;
}
Пример #8
0
static int aes_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV) {
  int mode=GCRY_CIPHER_MODE_CBC;
  if (cipher->key == NULL) {
    if (alloc_key(cipher) < 0) {
      return -1;
    }
    if(strstr(cipher->name,"-ctr"))
      mode=GCRY_CIPHER_MODE_CTR;
    switch (cipher->keysize) {
      case 128:
        if (gcry_cipher_open(&cipher->key[0], GCRY_CIPHER_AES128,
              mode, 0)) {
          SAFE_FREE(cipher->key);
          return -1;
        }
        break;
      case 192:
        if (gcry_cipher_open(&cipher->key[0], GCRY_CIPHER_AES192,
              mode, 0)) {
          SAFE_FREE(cipher->key);
          return -1;
        }
        break;
      case 256:
        if (gcry_cipher_open(&cipher->key[0], GCRY_CIPHER_AES256,
              mode, 0)) {
          SAFE_FREE(cipher->key);
          return -1;
        }
        break;
    }
    if (gcry_cipher_setkey(cipher->key[0], key, cipher->keysize / 8)) {
      SAFE_FREE(cipher->key);
      return -1;
    }
    if(mode == GCRY_CIPHER_MODE_CBC){
      if (gcry_cipher_setiv(cipher->key[0], IV, 16)) {

        SAFE_FREE(cipher->key);
        return -1;
      }
    } else {
      if(gcry_cipher_setctr(cipher->key[0],IV,16)){
        SAFE_FREE(cipher->key);
        return -1;
      }
    }
  }

  return 0;
}
Пример #9
0
static int aes_set_encrypt_key(struct ssh_cipher_struct *cipher, void *key,
    void *IV) {
  if (cipher->key == NULL) {
    if (alloc_key(cipher) < 0) {
      return -1;
    }
    if (AES_set_encrypt_key(key,cipher->keysize,cipher->key) < 0) {
      SAFE_FREE(cipher->key);
      return -1;
    }
  }
  cipher->IV=IV;
  return 0;
}
Пример #10
0
static int des3_1_set_key(struct crypto_struct *cipher, void *key, void *IV) {
  if (cipher->key == NULL) {
    if (alloc_key(cipher) < 0) {
      return -1;
    }
    if (gcry_cipher_open(&cipher->key[0], GCRY_CIPHER_DES,
          GCRY_CIPHER_MODE_CBC, 0)) {
      SAFE_FREE(cipher->key);
      return -1;
    }
    if (gcry_cipher_setkey(cipher->key[0], key, 8)) {
      SAFE_FREE(cipher->key);
      return -1;
    }
    if (gcry_cipher_setiv(cipher->key[0], IV, 8)) {
      SAFE_FREE(cipher->key);
      return -1;
    }

    if (gcry_cipher_open(&cipher->key[1], GCRY_CIPHER_DES,
          GCRY_CIPHER_MODE_CBC, 0)) {
      SAFE_FREE(cipher->key);
      return -1;
    }
    if (gcry_cipher_setkey(cipher->key[1], key + 8, 8)) {
      SAFE_FREE(cipher->key);
      return -1;
    }
    if (gcry_cipher_setiv(cipher->key[1], IV + 8, 8)) {
      SAFE_FREE(cipher->key);
      return -1;
    }

    if (gcry_cipher_open(&cipher->key[2], GCRY_CIPHER_DES,
          GCRY_CIPHER_MODE_CBC, 0)) {
      SAFE_FREE(cipher->key);
      return -1;
    }
    if (gcry_cipher_setkey(cipher->key[2], key + 16, 8)) {
      SAFE_FREE(cipher->key);
      return -1;
    }
    if (gcry_cipher_setiv(cipher->key[2], IV + 16, 8)) {
      SAFE_FREE(cipher->key);
      return -1;
    }
  }

  return 0;
}
Пример #11
0
CAMLprim value xmlsecml_xmlSecKeyGenerate(value camlId, value camlSize, value camlType)
{
  CAMLparam3(camlId, camlSize, camlType);
  xmlSecKeyDataId id;
  xmlSecSize size;
  xmlSecKeyDataType type;
  xmlSecKeyPtr key = NULL;
  assert ( Is_long(camlId) );
  id = xmlSecKeyDataAesId;
  size = Int_val(camlSize);
  type = Int_val(camlType);
  key = xmlSecKeyGenerate(id, size, type);
  assert(key != NULL);
  CAMLreturn(alloc_key(key));
}
Пример #12
0
static int des3_set_key(struct crypto_struct *cipher, void *key) {
  if (cipher->key == NULL) {
    if (alloc_key(cipher) < 0) {
      return -1;
    }

    DES_set_odd_parity(key);
    DES_set_odd_parity(key + 8);
    DES_set_odd_parity(key + 16);
    DES_set_key_unchecked(key, cipher->key);
    DES_set_key_unchecked(key + 8, cipher->key + sizeof(DES_key_schedule));
    DES_set_key_unchecked(key + 16, cipher->key + 2 * sizeof(DES_key_schedule));
  }

  return 0;
}
Пример #13
0
static int des3_set_key(struct ssh_cipher_struct *cipher, void *key,void *IV) {
  if (cipher->key == NULL) {
    if (alloc_key(cipher) < 0) {
      return -1;
    }

    DES_set_odd_parity(key);
    DES_set_odd_parity((void*)((uint8_t*)key + 8));
    DES_set_odd_parity((void*)((uint8_t*)key + 16));
    DES_set_key_unchecked(key, cipher->key);
    DES_set_key_unchecked((void*)((uint8_t*)key + 8), (void*)((uint8_t*)cipher->key + sizeof(DES_key_schedule)));
    DES_set_key_unchecked((void*)((uint8_t*)key + 16), (void*)((uint8_t*)cipher->key + 2 * sizeof(DES_key_schedule)));
  }
  cipher->IV=IV;
  return 0;
}
Пример #14
0
static int aes_set_key(struct crypto_struct *cipher, void *key, void *IV) {
  if (cipher->key == NULL) {
    if (alloc_key(cipher) < 0) {
      return -1;
    }

    switch (cipher->keysize) {
      case 128:
        if (gcry_cipher_open(&cipher->key[0], GCRY_CIPHER_AES128,
              GCRY_CIPHER_MODE_CBC, 0)) {
          SAFE_FREE(cipher->key);
          return -1;
        }
        break;
      case 192:
        if (gcry_cipher_open(&cipher->key[0], GCRY_CIPHER_AES192,
              GCRY_CIPHER_MODE_CBC, 0)) {
          SAFE_FREE(cipher->key);
          return -1;
        }
        break;
      case 256:
        if (gcry_cipher_open(&cipher->key[0], GCRY_CIPHER_AES256,
              GCRY_CIPHER_MODE_CBC, 0)) {
          SAFE_FREE(cipher->key);
          return -1;
        }
        break;
    }
    if (gcry_cipher_setkey(cipher->key[0], key, cipher->keysize / 8)) {
      SAFE_FREE(cipher->key);
      return -1;
    }
    if (gcry_cipher_setiv(cipher->key[0], IV, 16)) {
      SAFE_FREE(cipher->key);
      return -1;
    }
  }

  return 0;
}
Пример #15
0
/* the wrapper functions for blowfish */
static int blowfish_set_key(struct crypto_struct *cipher, void *key, void *IV){
  if (cipher->key == NULL) {
    if (alloc_key(cipher) < 0) {
      return -1;
    }

    if (gcry_cipher_open(&cipher->key[0], GCRY_CIPHER_BLOWFISH,
        GCRY_CIPHER_MODE_CBC, 0)) {
      SAFE_FREE(cipher->key);
      return -1;
    }
    if (gcry_cipher_setkey(cipher->key[0], key, 16)) {
      SAFE_FREE(cipher->key);
      return -1;
    }
    if (gcry_cipher_setiv(cipher->key[0], IV, 8)) {
      SAFE_FREE(cipher->key);
      return -1;
    }
  }

  return 0;
}
Пример #16
0
static int
get_cmdvec (char * cmd, vector *v)
{
	int i;
	int r = 0;
	int get_param = 0;
	char * buff;
	struct key * kw = NULL;
	struct key * cmdkw = NULL;
	vector cmdvec, strvec;

	strvec = alloc_strvec(cmd);
	if (!strvec)
		return E_NOMEM;

	cmdvec = vector_alloc();

	if (!cmdvec) {
		free_strvec(strvec);
		return E_NOMEM;
	}

	vector_foreach_slot(strvec, buff, i) {
		if (*buff == '"')
			continue;
		if (get_param) {
			get_param = 0;
			cmdkw->param = strdup(buff);
			continue;
		}
		kw = find_key(buff);
		if (!kw) {
			r = E_SYNTAX;
			goto out;
		}
		cmdkw = alloc_key();
		if (!cmdkw) {
			r = E_NOMEM;
			goto out;
		}
		if (!vector_alloc_slot(cmdvec)) {
			FREE(cmdkw);
			r = E_NOMEM;
			goto out;
		}
		vector_set_slot(cmdvec, cmdkw);
		cmdkw->code = kw->code;
		cmdkw->has_param = kw->has_param;
		if (kw->has_param)
			get_param = 1;
	}
	if (get_param) {
		r = E_NOPARM;
		goto out;
	}
	*v = cmdvec;
	free_strvec(strvec);
	return 0;

out:
	free_strvec(strvec);
	free_keys(cmdvec);
	return r;
}
Пример #17
0
void * f(void * x) {
  alloc_key();
  return 0;
}
Пример #18
0
/*
 * キーボード割り込みによって起動される関数。
 *
 * キーボードデバイスからキーイベントを読み取り、入力バッファ (input_buffer) 
 * に追加する。
 */
W
intr_kbd ()
{
  W			key_code;
  W			ch;
  struct key_entry	*key;
  ER			error;
  
  while ((inb (KEY_STAT) & 0x02) == 0)
    ;
  outb (KEY_COM, 0x16);
  key_code = inb (0x41);

  if ((key_code & 0x70) == 0x70)
    {
      switch (key_code)
	{
	case 0x70:
	  shiftkey_code |= SHIFT_DOWN;
	  break;
	case 0x71:
	  capskey = CAPS_DOWN;
	  break;
	case 0x73:
	  shiftkey_code |= GRAPH_DOWN;
	  break;
	case 0x74:
	  shiftkey_code |= CONTROL_DOWN;
	  break;
	case 0xf0:
	  shiftkey_code &= ~SHIFT_DOWN;
	  break;
	case 0xf1:
	  capskey = NORMAL;
	  break;
	case 0xf3:
	  shiftkey_code &= ~GRAPH_DOWN;
	  break;

	case 0xf4:
	  shiftkey_code &= ~CONTROL_DOWN;
	  break;
	}
      return;
    }
  
  /* もし、キーを離したところならば、無視する */
  if (key_code & 0x80)
    return;
  
  /* マトリックステーブルから、キーコードを取り出す。
   */
  if (shiftkey_code & CONTROL_DOWN)
    ch = key_table[CONTROL_CODE][key_code];
  else if (capskey)
    {
      if (shiftkey_code & SHIFT_DOWN)
	ch = key_table[NORMAL_CODE][key_code];
      else
	ch = key_table[SHIFT_CODE][key_code];
    }
  else if (shiftkey_code & SHIFT_DOWN)
    ch = key_table[SHIFT_DOWN][key_code];
  else
    ch = key_table[NORMAL_CODE][key_code];

  if (ch == NULL)
    return;
  
  dis_int ();
  key = alloc_key (ch);
  if (key == NULL)		/* キーがない */
    {
      ena_int ();
      return;
    }

  if (input_buffer.last)
    {
      input_buffer.last->next = key;
      input_buffer.last = key;
    }
  else
    {
      input_buffer.first = input_buffer.last = key;
    }
  ena_int ();

/*  printk ("key code = 0x%x, char = 0x%x", key_code, ch);	/* */
#if 0  
  if (ch != 0)
    {
      B buf[2];

      buf[0] = ch;
      buf[1] = '\0';
      printk ("(");
      printk (buf);
      printk (")\n");
    }
  else
    printk ("(NULL)\n", ch);
#endif /* 0 */
  if (ch == ('s' - 'a' + 1))
    {
      falldown ("control S\n");
    }
  else if (ch == ('l' - 'a' + 1))
    {
      print_task_list ();
    }

  if ((error = wup_tsk (ITRON_KEYBOARD)) != E_OK)
    {
      printk ("errno = %d\n", error);
      falldown ("intr_kbd: error on wup_tsk.\n");
    }
}