14#ifndef ENIGMA_FLAG_X_SEPARATED
18#define ENIGMA_FLAG_X_SEPARATED 16
21#ifndef ENIGMA_DICTIONARY_EXISTS
25#define ENIGMA_DICTIONARY_EXISTS 1
28#ifndef ENIGMA_N_GRAMS_EXIST
32#define ENIGMA_N_GRAMS_EXIST 2
35#ifndef ENIGMA_IOC_FREQS_EXIST
39#define ENIGMA_IOC_FREQS_EXIST 4
42#ifndef ENIGMA_CIPHERTEXT_EXISTS
46#define ENIGMA_CIPHERTEXT_EXISTS 8
49#ifndef ENIGMA_SCORE_BOUNDS_EXIST
53#define ENIGMA_SCORE_BOUNDS_EXIST 16
56#ifndef ENIGMA_ROTORS_DEFINED
61#define ENIGMA_ROTORS_DEFINED 32
64#ifndef ENIGMA_ROTOR_POSITIONS_DEFINED
69#define ENIGMA_ROTOR_POSITIONS_DEFINED 64
72#ifndef ENIGMA_REFLECTOR_DEFINED
77#define ENIGMA_REFLECTOR_DEFINED 128
80#ifndef ENIGMA_PLUGBOARD_DEFINED
85#define ENIGMA_PLUGBOARD_DEFINED 256
103 float frequency_targets[26];
int enigma_crack_set_dictionary(EnigmaCrackParams *, const char **, size_t)
Set the dictionary field in the given EnigmaCrackParams struct.
Definition: crack.c:950
int enigma_crack_rotor_position(EnigmaCrackParams *, int, float(*scoreFunc)(const EnigmaCrackParams *, const char *))
Crack a rotor's position using a scoring function.
Definition: crack.c:338
const char ** enigma_crack_get_dictionary(const EnigmaCrackParams *)
Get the dictionary field in the given EnigmaCrackParams struct.
Definition: crack.c:713
int enigma_crack_set_score_list(EnigmaCrackParams *, EnigmaScoreList *)
Set the score_list field in the given EnigmaCrackParams struct.
Definition: crack.c:931
EnigmaCrackParams * enigma_crack_params_new(void)
Create a new EnigmaCrackParams structure.
Definition: crack.c:36
float enigma_crack_get_target_score(const EnigmaCrackParams *)
Get the target_score field in the given EnigmaCrackParams struct.
Definition: crack.c:871
int enigma_crack_rotor(EnigmaCrackParams *, int, float(*)(const EnigmaCrackParams *, const char *))
Crack the rotor using a scoring function.
Definition: crack.c:232
int enigma_score_append(EnigmaCrackParams *, Enigma *, const char *, float)
Append a score to an EnigmaScoreList.
Definition: crack.c:604
const EnigmaScoreList * enigma_crack_get_score_list(const EnigmaCrackParams *)
Get the score_list field in the given EnigmaCrackParams struct.
Definition: crack.c:698
int enigma_find_potential_indices(const char *, const char *, int *)
Finds potential indices in the ciphertext where the known plaintext may exist.
Definition: crack.c:498
int enigma_letter_freq(const EnigmaCrackParams *, const char *)
Check if the letter frequencies in the plaintext match target frequencies within an offset.
Definition: crack.c:567
int enigma_crack_params_validate(const EnigmaCrackParams *)
Check what capabilities the EnigmaCrackParams structure has.
Definition: crack.c:59
int enigma_crack_set_max_score(EnigmaCrackParams *, float)
Set the maximum score field in the given EnigmaCrackParams struct.
Definition: crack.c:1072
int enigma_crack_set_n(EnigmaCrackParams *, int)
Set the n field in the given EnigmaCrackParams struct.
Definition: crack.c:988
const float * enigma_crack_get_ngrams(const EnigmaCrackParams *)
Get the ngrams field in the given EnigmaCrackParams struct.
Definition: crack.c:742
size_t enigma_crack_get_dictionary_length(const EnigmaCrackParams *)
Get the dictionary_length field in the given EnigmaCrackParams struct.
Definition: crack.c:728
int enigma_crack_plugboard(EnigmaCrackParams *, float(*)(const EnigmaCrackParams *, const char *))
Crack the plugboard using a scoring function.
Definition: crack.c:136
int enigma_crack_set_known_plaintext(EnigmaCrackParams *, const char *, size_t)
Set the known plaintext field in the given EnigmaCrackParams struct.
Definition: crack.c:1105
int enigma_crack_set_min_score(EnigmaCrackParams *, float)
Set the minimum score field in the given EnigmaCrackParams struct.
Definition: crack.c:1056
const Enigma * enigma_crack_get_enigma(const EnigmaCrackParams *)
Get the enigma field in the given EnigmaCrackParams struct.
Definition: crack.c:682
int enigma_score_flags(const EnigmaCrackParams *, const char *)
Get the flags for a given plaintext based on the crack configuration.
Definition: crack.c:636
int enigma_crack_set_enigma(EnigmaCrackParams *, Enigma *)
Set the enigma field in the given EnigmaCrackParams struct.
Definition: crack.c:915
size_t enigma_crack_get_known_plaintext_length(const EnigmaCrackParams *)
Get the known_plaintext_length field in the given EnigmaCrackParams struct.
Definition: crack.c:900
int enigma_crack_set_target_score(EnigmaCrackParams *, float)
Set the target score field in the given EnigmaCrackParams struct.
Definition: crack.c:1088
int enigma_dict_match(const EnigmaCrackParams *, const char *)
Checks if multiple words from the dictionary are present in the plaintext.
Definition: crack.c:436
int enigma_crack_set_ciphertext(EnigmaCrackParams *, const char *, size_t)
Set the ciphertext field in the given EnigmaCrackParams struct.
Definition: crack.c:1006
int enigma_crack_reflector(EnigmaCrackParams *, float(*)(const EnigmaCrackParams *, const char *))
Crack the reflector using a scoring function.
Definition: crack.c:194
size_t enigma_crack_get_ciphertext_length(const EnigmaCrackParams *)
Get the ciphertext_length field in the given EnigmaCrackParams struct.
Definition: crack.c:800
size_t enigma_crack_get_ngrams_length(const EnigmaCrackParams *)
Get the ngrams_length field in the given EnigmaCrackParams struct.
Definition: crack.c:771
int enigma_crack_rotors(EnigmaCrackParams *, float(*)(const EnigmaCrackParams *, const char *))
Crack the rotor order using a scoring function.
Definition: crack.c:269
const char * enigma_crack_get_ciphertext(const EnigmaCrackParams *)
Get the ciphertext field in the given EnigmaCrackParams struct.
Definition: crack.c:785
int enigma_crack_set_flags(EnigmaCrackParams *, int)
Set the flags field in the given EnigmaCrackParams struct.
Definition: crack.c:1023
const float * enigma_crack_get_frequency_targets(const EnigmaCrackParams *)
Get the frequency_targets field in the given EnigmaCrackParams struct.
Definition: crack.c:828
float enigma_freq(const char *, int)
Calculate the frequency of characters in the plaintext.
Definition: crack.c:532
int enigma_crack_get_n(const EnigmaCrackParams *)
Get the n field in the given EnigmaCrackParams struct.
Definition: crack.c:757
int enigma_crack_rotor_positions(EnigmaCrackParams *, float(*)(const EnigmaCrackParams *, const char *))
Crack the rotor positions using a scoring function.
Definition: crack.c:372
int enigma_crack_set_ngrams(EnigmaCrackParams *, float *, int, size_t)
Set the ngrams field in the given EnigmaCrackParams struct.
Definition: crack.c:970
int enigma_crack_get_flags(const EnigmaCrackParams *)
Get the flags field in the given EnigmaCrackParams struct.
Definition: crack.c:814
float enigma_crack_get_max_score(const EnigmaCrackParams *)
Get the max_score field in the given EnigmaCrackParams struct.
Definition: crack.c:857
const char * enigma_crack_get_known_plaintext(const EnigmaCrackParams *)
Get the known_plaintext field in the given EnigmaCrackParams struct.
Definition: crack.c:885
int enigma_crack_set_frequency_targets(EnigmaCrackParams *, float *)
Set the frequency targets field in the given EnigmaCrackParams struct.
Definition: crack.c:1039
float enigma_crack_get_min_score(const EnigmaCrackParams *)
Get the min_score field in the given EnigmaCrackParams struct.
Definition: crack.c:843
A structure representing a configuration for cracking an Enigma cipher.
Definition: crack.h:92
Enigma enigma
The base enigma machine configuration.
Definition: crack.h:93
int known_plaintext_length
The length of the known plaintext.
Definition: crack.h:112
float * ngrams
An array of n-gram frequencies.
Definition: crack.h:97
size_t dictionary_length
The number of words in the dictionary.
Definition: crack.h:96
EnigmaScoreList * score_list
A list of scored configurations.
Definition: crack.h:94
const char * ciphertext
The ciphertext to be cracked.
Definition: crack.h:100
int n
The length of each n-gram.
Definition: crack.h:98
const char ** dictionary
A list of dictionary words (should be sorted and all uppercase)
Definition: crack.h:95
float min_score
The minimum score for a configuration to be considered.
Definition: crack.h:104
const char * known_plaintext
Known plaintext that must exist for a configuration to be considered.
Definition: crack.h:111
int flags
Flags indicating special conditions a scored configuration may meet.
Definition: crack.h:102
size_t ciphertext_length
The length of the ciphertext.
Definition: crack.h:101
float frequency_offset
The maximum offset from the target frequency that a scored configuration may have to be considered va...
Definition: crack.h:109
float target_frequency
The target frequency for a configuration to be considered.
Definition: crack.h:107
float max_score
The maximum score for a configuration to be considered.
Definition: crack.h:105
float target_score
The target score for a configuration to be considered.
Definition: crack.h:106
size_t ngrams_length
The number of n-grams in the array.
Definition: crack.h:99
A structure representing a list of scored Enigma configurations.
Definition: score.h:40
Represents the state and configuration of an Enigma machine.
Definition: enigma.h:34