Lines Matching refs:salt
181 struct salt { struct
182 unsigned char *salt; member
188 struct salt *salt_list; argument
193 static struct salt *find_by_salt(unsigned char *salt, size_t salt_len) in find_by_salt() argument
196 struct salt *p; in find_by_salt()
200 !memcmp(p->salt, salt, salt_len)) in find_by_salt()
205 static void add_salt(unsigned char *salt, size_t salt_len) in add_salt() argument
207 if (find_by_salt(salt, salt_len)) in add_salt()
211 salt_list = realloc(salt_list, max_salt * sizeof(struct salt)); in add_salt()
217 salt_list[num_salt].salt = salt; in add_salt()
225 memset(salt_list, 0, sizeof(struct salt) * max_salt); in clear_secrets()
348 static void set_policy(struct salt *set_salt, int pad, in set_policy()
351 struct salt *salt; in set_policy() local
371 salt = set_salt; in set_policy()
378 salt = find_by_salt(uu, sizeof(uu)); in set_policy()
379 if (!salt) { in set_policy()
390 memcpy(policy.master_key_descriptor, salt->key_desc, in set_policy()
398 strerror(errno), salt->key_ref_str, argv[x]); in set_policy()
402 salt->key_ref_str, argv[x]); in set_policy()
406 static void pbkdf2_sha512(const char *passphrase, struct salt *salt, in pbkdf2_sha512() argument
426 if (salt->salt_len > EXT4_MAX_SALT_SIZE) { in pbkdf2_sha512()
427 printf("Salt size is %zd; max is %d.\n", salt->salt_len, in pbkdf2_sha512()
433 memcpy(saltbuf, salt->salt, salt->salt_len); in pbkdf2_sha512()
531 static void generate_key_ref_str(struct salt *salt) in generate_key_ref_str() argument
537 ext2fs_sha512(salt->key, EXT4_MAX_KEY_SIZE, key_ref1); in generate_key_ref_str()
539 memcpy(salt->key_desc, key_ref2, EXT4_KEY_DESCRIPTOR_SIZE); in generate_key_ref_str()
541 sprintf(&salt->key_ref_str[x * 2], "%02x", in generate_key_ref_str()
542 salt->key_desc[x]); in generate_key_ref_str()
544 salt->key_ref_str[EXT4_KEY_REF_STR_BUF_SIZE - 1] = '\0'; in generate_key_ref_str()
547 static void insert_key_into_keyring(const char *keyring, struct salt *salt) in insert_key_into_keyring() argument
560 salt->key_ref_str); in insert_key_into_keyring()
566 salt->key_ref_str); in insert_key_into_keyring()
575 memcpy(key.raw, salt->key, EXT4_MAX_KEY_SIZE); in insert_key_into_keyring()
605 "%s\n", salt->key_ref_str, strerror(errno)); in insert_key_into_keyring()
611 salt->key_ref_str); in insert_key_into_keyring()
655 struct salt *salt; in do_add_key() local
707 for (j = 0, salt = salt_list; j < num_salt; j++, salt++) { in do_add_key()
708 pbkdf2_sha512(in_passphrase, salt, in do_add_key()
709 EXT4_PBKDF2_ITERATIONS, salt->key); in do_add_key()
710 generate_key_ref_str(salt); in do_add_key()
711 insert_key_into_keyring(keyring, salt); in do_add_key()
714 salt = explicit_salt ? salt_list : NULL; in do_add_key()
715 set_policy(salt, pad, argc, argv, optind); in do_add_key()
732 struct salt saltbuf; in do_set_policy()