コード例 #1
0
ファイル: asciipasswd.c プロジェクト: AndreasHack/tbamud
int main(int argc, char **argv) {
  if (argc != 3)
    fprintf(stderr, "Usage: %s name password\n", argv[0]);
  else
    printf("Name: %s\nPass: %s\n", CAP(argv[1]), CRYPT(argv[2], CAP(argv[1])));
  return (0);
}
コード例 #2
0
ファイル: efuns_port.c プロジェクト: Yuffster/fluffOS
void
f_crypt (void)
{
    const char *res, *p;
    char salt[SALT_LEN + 1];
    const char *choice =
    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ./";

    if (sp->type == T_STRING && SVALUE_STRLEN(sp) >= 2) {
        p = sp->u.string;
    } else {
        int i;
        
        for (i = 0; i < SALT_LEN; i++)
            salt[i] = choice[random_number(strlen(choice))];

        salt[SALT_LEN] = 0;
        p = salt;
    }
    
    res = string_copy(CRYPT((sp-1)->u.string, p), "f_crypt");
    pop_stack();
    free_string_svalue(sp);
    sp->subtype = STRING_MALLOC;
    sp->u.string = res;
}
コード例 #3
0
ファイル: Signer.cpp プロジェクト: andreev3344/samp
BOOL CSigner::VerifySignature(CHasher *pHasher, CKeyPair *pKeyPair)
{
	HCRYPTHASH hCryptHash = pHasher->GetContainer();
	HCRYPTKEY hCryptKey = pKeyPair->GetContainer();
	BOOL bVerify;

	bVerify = CRYPT(VerifySignature)(hCryptHash, m_pbSignature, m_dwLength, hCryptKey, NULL, CRYPT_NOHASHOID);

	return bVerify;
}
コード例 #4
0
ファイル: cascade.c プロジェクト: macssh/macssh
static void do_cascade_crypt(struct crypto_instance *s,
			     UINT32 length, const UINT8 *src, UINT8 *dst)
{
  CAST(crypto_cascade_instance, self, s);
  unsigned i;
  
  if (length % self->super.block_size)
    fatal("Internal error!\n");

  assert(LIST_LENGTH(self->cascade));

  {
    CAST_SUBTYPE(crypto_instance, o, LIST(self->cascade)[0]);
    CRYPT(o, length, src, dst);
  }
  for (i = 1; i<LIST_LENGTH(self->cascade); i++)
    {
      CAST_SUBTYPE(crypto_instance, o, LIST(self->cascade)[i]);
      CRYPT(o, length, dst, dst);
    }
}
コード例 #5
0
ファイル: uucpd.c プロジェクト: Claruarius/stblinux-2.6.37
void
doit (struct sockaddr_in *sinp)
{
	struct passwd *pw, *getpwnam();
	char user[64], passwd[64];
	char *xpasswd;

	alarm(60);
	printf("login: "******"user read\n");
		return;
	}
	/* truncate username to 8 characters */
	user[8] = '\0';
	pw = getpwnam(user);
	if (pw == NULL) {
		fprintf(stderr, "user unknown\n");
		return;
	}
	if (strcmp(pw->pw_shell, PATH_UUCICO)) {
		fprintf(stderr, "Login incorrect.");
		return;
	}
	if (pw->pw_passwd && *pw->pw_passwd != '\0') {
		printf("Password: "******"passwd read\n");
			return;
		}
		xpasswd = CRYPT (passwd, pw->pw_passwd);
		if (strcmp(xpasswd, pw->pw_passwd)) {
			fprintf(stderr, "Login incorrect.");
			return;
		}
	}
	alarm(0);
	sprintf(Username, "USER=%s", user);
	dologin(pw, sinp);
	setgid(pw->pw_gid);
#ifdef BSD4_2
	initgroups(pw->pw_name, pw->pw_gid);
#endif /* BSD4_2 */
	chdir(pw->pw_dir);
	setuid(pw->pw_uid);
#ifdef BSD4_2
	execl(UUCICO, "uucico", (char *)0);
#endif /* BSD4_2 */
	perror("uucico server: execl");
}
コード例 #6
0
void pword(char *filename, char *name, char *password) {
	FILE *fl;
	struct char_file_u buf;
	int found = FALSE;
	long size;

	if (!(fl = fopen(filename, "r+"))) {
		perror(filename);
		exit(1);
	}
	fseek(fl, 0L, SEEK_END);
	size = ftell(fl);
	rewind(fl);
	if (size % sizeof(struct char_file_u)) {
		fprintf(stderr, "\aWARNING:  File size does not match structure, recompile mudpasswd.\n");
		fclose(fl);
		exit(1);
	}

	for (;;) {
		fread(&buf, sizeof(buf), 1, fl);
		if (feof(fl))
			break;

		if (str_eq(name, buf.name)) {
			found = TRUE;
			strncpy(buf.pwd, CRYPT(password, PASSWORD_SALT), MAX_PWD_LENGTH);
			if (fseek(fl, -1L * sizeof(buf), SEEK_CUR) != 0)
				perror("fseek");
			if (fwrite(&buf, sizeof(buf), 1, fl) != 1)
				perror("fwrite");
			if (fseek(fl, 0L, SEEK_CUR) != 0)
				perror("fseek");
		}
	}

	if (found)
		printf("%s password is now %s\n", name, password);
	else
		printf("%s not found\n", name);

	fclose(fl);
}
コード例 #7
0
ファイル: passwd.c プロジェクト: jsravn/darkpawns
void passwd(char *filename, char *playername, char *newpasswd)
{
  FILE *fl;
  FILE *outfile;
  struct char_file_u player;
  long size;

  if (!(fl = fopen(filename, "r+"))) {
    printf("Can't open %s.", filename);
    exit(1);
  }
  fseek(fl, 0L, SEEK_END);
  size = ftell(fl);
  rewind(fl);
  if (size % sizeof(struct char_file_u)) {
    fprintf(stderr, "\aWARNING:  File size does not match structure, recompile.\r\n");
    fclose(fl);
    exit(1);
  }

  outfile = fopen("players.new", "w");

  for (;;) {
    fread(&player, sizeof(struct char_file_u), 1, fl);
     
    if (feof(fl)) {
      fclose(fl);
      fclose(outfile);
      printf("Done.\n");
      exit(0);
    }
      if (!strcmp(player.name, playername))
      {
        strncpy(player.pwd, CRYPT(newpasswd, player.name), MAX_PWD_LENGTH);
        *(player.pwd + MAX_PWD_LENGTH) = '\0';
      }
      fwrite(&player, sizeof(struct char_file_u), 1, outfile);


  }
}
コード例 #8
0
ファイル: KeyPair.cpp プロジェクト: andreev3344/samp
void CKeyPair::LoadFromMemory(DWORD dwPubKeySize, BYTE* pbPubKeyBlob, BYTE bytXORKey)
{
	BYTE *pbKeyBlob;

	// Un-XOR keys from memory
	if (bytXORKey != 0) {
		pbKeyBlob = new BYTE[dwPubKeySize];
		for(DWORD i=0; i<dwPubKeySize; i++)
			pbKeyBlob[i] = pbPubKeyBlob[i] ^ bytXORKey;
	} else {
		pbKeyBlob = pbPubKeyBlob;
	}

	// Import the key
	HCRYPTPROV hCryptProv = m_pContext->GetProvider();
	CRYPT(ImportKey)(hCryptProv, pbKeyBlob, dwPubKeySize, NULL, NULL, &m_hCryptKey);

	// Clean up
	if (bytXORKey != 0) {
		delete[] pbKeyBlob;
	}

}
コード例 #9
0
ファイル: KeyPair.cpp プロジェクト: andreev3344/samp
void CKeyPair::ReleaseKey() 
{
	// Destroy the key pair
	CRYPT(DestroyKey)(m_hCryptKey);
	m_hCryptKey = NULL;
}
コード例 #10
0
ファイル: encrypt.c プロジェクト: jeremyfrench/lsh
struct lsh_string *
encrypt_packet(struct lsh_string *packet, struct compress_instance *compress,
	       struct crypto_instance *crypt, struct mac_instance *mac,
	       uint32_t seqno)
{
  uint32_t block_size;
  uint32_t new_size;
  uint8_t padding_length;
  uint32_t padding;

  uint32_t mac_length;
  uint32_t mac_start;

  uint32_t length = lsh_string_length(packet);
  assert(length);
  
  /* Deflate, pad, mac, encrypt. */
  if (compress)
    {
      struct lsh_string *n = lsh_string_alloc(SSH_MAX_PACKET + SSH_MAX_PACKET_FUZZ);

      length = CODEC(compress, n, 0,
		     lsh_string_length(packet), lsh_string_data(packet));

      assert(length > 0);
      lsh_string_trunc(n, length);

      lsh_string_free(packet);
      packet = n;
    }

  block_size = crypt ? crypt->block_size : 8;
  mac_length = mac ? mac->mac_size : 0;
  
  /* new_size is (length + 9) rounded up to a multiple of
   * block_size */
  new_size = block_size * (1 + (8 + length) / block_size);
  
  padding_length = new_size - length - 5;
  assert(padding_length >= 4);

  packet = ssh_format("%i%c%lfS%lr%lr",
		      length + padding_length + 1,
		      padding_length,
		      packet,
		      padding_length, &padding,
		      mac_length, &mac_start);

  assert(new_size + mac_length == lsh_string_length(packet));

  lsh_string_write_random(packet, padding, padding_length);

  if (mac)
    {
      uint8_t s[4];
      assert(new_size == mac_start);      

      WRITE_UINT32(s, seqno);
      MAC_UPDATE(mac, 4, s);
      MAC_UPDATE(mac, new_size, lsh_string_data(packet));
      MAC_DIGEST(mac, packet, mac_start);
    }
  if (crypt)
    CRYPT(crypt, new_size, packet, 0, packet, 0);

  return packet;
}