-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBF_std.h
101 lines (83 loc) · 1.93 KB
/
BF_std.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* This file is part of John the Ripper password cracker,
* Copyright (c) 1996-2001,2008,2010,2011 by Solar Designer
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted.
*
* There's ABSOLUTELY NO WARRANTY, express or implied.
*/
/*
* OpenBSD-style Blowfish-based password hash implementation.
*/
#ifndef _JOHN_BF_STD_H
#define _JOHN_BF_STD_H
#include <stdint.h>
#include "arch.h"
typedef uint32_t BF_word;
/*
* Binary salt type, also keeps the number of rounds and hash sub-type.
*/
typedef struct {
BF_word salt[4];
unsigned char rounds;
char subtype;
} BF_salt;
/*
* Binary ciphertext type.
*/
typedef BF_word BF_binary[6];
#if BF_X2 == 3
#define BF_Nmin 3
#elif BF_X2
#define BF_Nmin 2
#else
#define BF_Nmin 1
#endif
#if defined(_OPENMP) && !BF_ASM
#define BF_cpt 3
#define BF_mt 1024
#define BF_N (BF_Nmin * BF_mt)
#else
#define BF_mt 1
#define BF_N BF_Nmin
#endif
/*
* BF_std_crypt() output buffer.
*/
extern BF_binary BF_out[BF_N];
/*
* ASCII to binary conversion table, for use in BF_fmt.valid().
*/
extern unsigned char BF_atoi64[0x80];
#if BF_X2 == 3
#define BF_ALGORITHM_NAME "Blowfish 32/" ARCH_BITS_STR " X3"
#elif BF_X2
#define BF_ALGORITHM_NAME "Blowfish 32/" ARCH_BITS_STR " X2"
#else
#define BF_ALGORITHM_NAME "Blowfish 32/" ARCH_BITS_STR
#endif
/*
* Sets a key for BF_std_crypt().
*/
extern void BF_std_set_key(char *key, int index, int sign_extension_bug);
/*
* Main hashing routine, sets first two words of BF_out
* (or all words in an OpenMP-enabled build).
*/
extern void BF_std_crypt(BF_salt *salt, int n);
#if BF_mt == 1
/*
* Calculates the rest of BF_out, for exact comparison.
*/
extern void BF_std_crypt_exact(int index);
#endif
/*
* Returns the salt for BF_std_crypt().
*/
extern void *BF_std_get_salt(char *ciphertext);
/*
* Converts an ASCII ciphertext to binary.
*/
extern void *BF_std_get_binary(char *ciphertext);
#endif