git ssb

0+

dangerousbeans / %aPBe2k3ugtjBr4rrsU1…



Tree: 271e1130133565a49a6056ea4947369569cb9701

Files: 271e1130133565a49a6056ea4947369569cb9701 / ext / bcrypt.h

1605 bytesRaw
1#include <stdio.h>
2#include <stdlib.h>
3#include <sys/types.h>
4#include <string.h>
5#include "blf.h"
6
7/* This implementation is adaptable to current computing power.
8 * You can have up to 2^31 rounds which should be enough for some
9 * time to come.
10 */
11
12#define BCRYPT_VERSION '2'
13#define BCRYPT_MAXSALT 16 /* Precomputation is just so nice */
14#define BCRYPT_BLOCKS 6 /* Ciphertext blocks */
15#define BCRYPT_MINROUNDS 16 /* we have log2(rounds) in salt */
16
17char *bcrypt_gensalt(u_int8_t, u_int8_t *);
18
19static void encode_salt(char *, u_int8_t *, u_int16_t, u_int8_t);
20static void encode_base64(u_int8_t *, u_int8_t *, u_int16_t);
21static void decode_base64(u_int8_t *, u_int16_t, u_int8_t *);
22
23static char encrypted[_PASSWORD_LEN];
24static char gsalt[7 + (BCRYPT_MAXSALT * 4 + 2) / 3 + 1];
25static char error[] = ":";
26
27const static u_int8_t Base64Code[] =
28"./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
29
30const static u_int8_t index_64[128] = {
31 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
32 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
33 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
34 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
35 255, 255, 255, 255, 255, 255, 0, 1, 54, 55,
36 56, 57, 58, 59, 60, 61, 62, 63, 255, 255,
37 255, 255, 255, 255, 255, 2, 3, 4, 5, 6,
38 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
39 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
40 255, 255, 255, 255, 255, 255, 28, 29, 30,
41 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
42 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
43 51, 52, 53, 255, 255, 255, 255, 255
44};
45#define CHAR64(c) ( (c) > 127 ? 255 : index_64[(c)])

Built with git-ssb-web