Lines Matching refs:length
60 static int encode_key(char *out, uint8_t *in, int length) in encode_key() argument
63 for (i = length; i > 0; --i, ++in, ++out) { in encode_key()
69 ++length; in encode_key()
73 return length; in encode_key()
76 static int decode_key(uint8_t *out, char *in, int length) in decode_key() argument
79 for (i = 0; i < length; ++i, ++in, ++out) { in decode_key()
85 --length; in decode_key()
89 return length; in decode_key()
104 static int recv_message(uint8_t *message, int length) in recv_message() argument
112 if (length < offset) { in recv_message()
115 length = offset; in recv_message()
117 while (offset < length) { in recv_message()
118 int n = recv(the_socket, &message[offset], length - offset, 0); in recv_message()
125 return length; in recv_message()
139 static void send_message(uint8_t *message, int length) in send_message() argument
141 uint16_t bytes = htons(length); in send_message()
143 send(the_socket, message, length, 0); in send_message()
164 int32_t length; member
171 int length; in encrypt_blob() local
178 length = blob.length + (blob.value - blob.encrypted); in encrypt_blob()
179 length = (length + AES_BLOCK_SIZE - 1) / AES_BLOCK_SIZE * AES_BLOCK_SIZE; in encrypt_blob()
182 memmove(&blob.encrypted[length], &blob.value[blob.length], blob.info); in encrypt_blob()
185 blob.length = htonl(blob.length); in encrypt_blob()
186 MD5(blob.digested, length - (blob.digested - blob.encrypted), blob.digest); in encrypt_blob()
189 AES_cbc_encrypt(blob.encrypted, blob.encrypted, length, aes_key, vector, in encrypt_blob()
193 length += (blob.encrypted - (uint8_t *)&blob) + blob.info; in encrypt_blob()
196 length -= write(fd, &blob, length); in encrypt_blob()
198 return (length || rename(".tmp", name)) ? SYSTEM_ERROR : NO_ERROR; in encrypt_blob()
204 int length; in decrypt_blob() local
209 length = read(fd, &blob, sizeof(blob)); in decrypt_blob()
212 length -= (blob.encrypted - (uint8_t *)&blob) + blob.info; in decrypt_blob()
213 if (length < blob.value - blob.encrypted || length % AES_BLOCK_SIZE != 0) { in decrypt_blob()
217 AES_cbc_encrypt(blob.encrypted, blob.encrypted, length, aes_key, in decrypt_blob()
219 length -= blob.digested - blob.encrypted; in decrypt_blob()
220 if (memcmp(blob.digest, MD5(blob.digested, length, NULL), in decrypt_blob()
225 length -= blob.value - blob.digested; in decrypt_blob()
226 blob.length = ntohl(blob.length); in decrypt_blob()
227 if (blob.length < 0 || blob.length > length) { in decrypt_blob()
231 memmove(&blob.value[blob.length], &blob.value[length], blob.info); in decrypt_blob()
252 int length; member
268 encode_key(&name[n], params[0].value, params[0].length); in get()
274 send_message(blob.value, blob.length); in get()
282 encode_key(&name[n], params[0].value, params[0].length); in insert()
284 blob.length = params[1].length; in insert()
285 memcpy(blob.value, params[1].value, params[1].length); in insert()
293 encode_key(&name[n], params[0].value, params[0].length); in delete()
301 encode_key(&name[n], params[0].value, params[0].length); in exist()
319 n += encode_key(&name[n], params[0].value, params[0].length); in saw()
324 params[0].length = decode_key(params[0].value, p, strlen(p)); in saw()
325 send_message(params[0].value, params[0].length); in saw()
356 static void set_key(uint8_t *key, uint8_t *password, int length, uint8_t *salt) in set_key() argument
359 PKCS5_PBKDF2_HMAC_SHA1((char *)password, length, salt, SALT_SIZE, in set_key()
362 PKCS5_PBKDF2_HMAC_SHA1((char *)password, length, (uint8_t *)"keystore", in set_key()
387 int length = read(fd, &blob, sizeof(blob)); in password() local
389 if (length > SALT_SIZE && blob.info == SALT_SIZE) { in password()
390 salt = (uint8_t *)&blob + length - SALT_SIZE; in password()
394 set_key(key, params[0].value, params[0].length, salt); in password()
400 if (response != NO_ERROR || blob.length != MASTER_KEY_SIZE) { in password()
408 if (!salt && params[1].length == -1) { in password()
413 if (params[1].length == -1) { in password()
421 set_key(key, params[1].value, params[1].length, salt); in password()
425 blob.length = MASTER_KEY_SIZE; in password()
448 params[1].length = -1; in unlock()
523 params[i].length = recv_message(params[i].value, action->lengths[i]); in process()
524 if (params[i].length == -1) { in process()