libenigma
Enigma machine utility library
Loading...
Searching...
No Matches
crack.c File Reference
#include "crack.h"
#include "common.h"
#include "enigma.h"
#include "io.h"
#include "rotor.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Macros

#define _POSIX_C_SOURCE   200809L
 

Functions

EnigmaCrackParamsenigma_crack_params_new (void)
 Create a new EnigmaCrackParams structure.
 
int enigma_crack_params_validate (const EnigmaCrackParams *cfg)
 Check what capabilities the EnigmaCrackParams structure has.
 
int enigma_crack_plugboard (EnigmaCrackParams *cfg, float(*scoreFunc)(const EnigmaCrackParams *, const char *))
 Crack the plugboard using a scoring function.
 
int enigma_crack_reflector (EnigmaCrackParams *cfg, float(*scoreFunc)(const EnigmaCrackParams *, const char *))
 Crack the reflector using a scoring function.
 
int enigma_crack_rotor (EnigmaCrackParams *cfg, int targetRotor, float(*scoreFunc)(const EnigmaCrackParams *, const char *))
 Crack the rotor using a scoring function.
 
int enigma_crack_rotors (EnigmaCrackParams *cfg, float(*scoreFunc)(const EnigmaCrackParams *, const char *))
 Crack the rotor order using a scoring function.
 
int enigma_crack_rotor_position (EnigmaCrackParams *cfg, int rotor, float(*scoreFunc)(const EnigmaCrackParams *, const char *))
 Crack a rotor's position using a scoring function.
 
int enigma_crack_rotor_positions (EnigmaCrackParams *cfg, float(*scoreFunc)(const EnigmaCrackParams *, const char *))
 Crack the rotor positions using a scoring function.
 
int enigma_dict_match (const EnigmaCrackParams *cfg, const char *plaintext)
 Checks if multiple words from the dictionary are present in the plaintext.
 
int enigma_find_potential_indices (const char *ciphertext, const char *plaintext, int *indices)
 Finds potential indices in the ciphertext where the known plaintext may exist.
 
float enigma_freq (const char *plaintext, int len)
 Calculate the frequency of characters in the plaintext.
 
int enigma_letter_freq (const EnigmaCrackParams *cfg, const char *plaintext)
 Check if the letter frequencies in the plaintext match target frequencies within an offset.
 
int enigma_score_append (EnigmaCrackParams *cfg, Enigma *enigma, const char *plaintext, float score)
 Append a score to an EnigmaScoreList.
 
int enigma_score_flags (const EnigmaCrackParams *cfg, const char *plaintext)
 Get the flags for a given plaintext based on the crack configuration.
 
const Enigmaenigma_crack_get_enigma (const EnigmaCrackParams *cfg)
 Get the enigma field in the given EnigmaCrackParams struct.
 
const EnigmaScoreListenigma_crack_get_score_list (const EnigmaCrackParams *cfg)
 Get the score_list field in the given EnigmaCrackParams struct.
 
const char ** enigma_crack_get_dictionary (const EnigmaCrackParams *cfg)
 Get the dictionary field in the given EnigmaCrackParams struct.
 
size_t enigma_crack_get_dictionary_length (const EnigmaCrackParams *cfg)
 Get the dictionary_length field in the given EnigmaCrackParams struct.
 
const float * enigma_crack_get_ngrams (const EnigmaCrackParams *cfg)
 Get the ngrams field in the given EnigmaCrackParams struct.
 
int enigma_crack_get_n (const EnigmaCrackParams *cfg)
 Get the n field in the given EnigmaCrackParams struct.
 
size_t enigma_crack_get_ngrams_length (const EnigmaCrackParams *cfg)
 Get the ngrams_length field in the given EnigmaCrackParams struct.
 
const char * enigma_crack_get_ciphertext (const EnigmaCrackParams *cfg)
 Get the ciphertext field in the given EnigmaCrackParams struct.
 
size_t enigma_crack_get_ciphertext_length (const EnigmaCrackParams *cfg)
 Get the ciphertext_length field in the given EnigmaCrackParams struct.
 
int enigma_crack_get_flags (const EnigmaCrackParams *cfg)
 Get the flags field in the given EnigmaCrackParams struct.
 
const float * enigma_crack_get_frequency_targets (const EnigmaCrackParams *cfg)
 Get the frequency_targets field in the given EnigmaCrackParams struct.
 
float enigma_crack_get_min_score (const EnigmaCrackParams *cfg)
 Get the min_score field in the given EnigmaCrackParams struct.
 
float enigma_crack_get_max_score (const EnigmaCrackParams *cfg)
 Get the max_score field in the given EnigmaCrackParams struct.
 
float enigma_crack_get_target_score (const EnigmaCrackParams *cfg)
 Get the target_score field in the given EnigmaCrackParams struct.
 
const char * enigma_crack_get_known_plaintext (const EnigmaCrackParams *cfg)
 Get the known_plaintext field in the given EnigmaCrackParams struct.
 
size_t enigma_crack_get_known_plaintext_length (const EnigmaCrackParams *cfg)
 Get the known_plaintext_length field in the given EnigmaCrackParams struct.
 
int enigma_crack_set_enigma (EnigmaCrackParams *cfg, Enigma *enigma)
 Set the enigma field in the given EnigmaCrackParams struct.
 
int enigma_crack_set_score_list (EnigmaCrackParams *cfg, EnigmaScoreList *scoreList)
 Set the score_list field in the given EnigmaCrackParams struct.
 
int enigma_crack_set_dictionary (EnigmaCrackParams *cfg, const char **dictionary, size_t length)
 Set the dictionary field in the given EnigmaCrackParams struct.
 
int enigma_crack_set_ngrams (EnigmaCrackParams *cfg, float *ngrams, int n, size_t length)
 Set the ngrams field in the given EnigmaCrackParams struct.
 
int enigma_crack_set_n (EnigmaCrackParams *cfg, int n)
 Set the n field in the given EnigmaCrackParams struct.
 
int enigma_crack_set_ciphertext (EnigmaCrackParams *cfg, const char *ciphertext, size_t length)
 Set the ciphertext field in the given EnigmaCrackParams struct.
 
int enigma_crack_set_flags (EnigmaCrackParams *cfg, int flags)
 Set the flags field in the given EnigmaCrackParams struct.
 
int enigma_crack_set_frequency_targets (EnigmaCrackParams *cfg, float *frequencyTargets)
 Set the frequency targets field in the given EnigmaCrackParams struct.
 
int enigma_crack_set_min_score (EnigmaCrackParams *cfg, float minScore)
 Set the minimum score field in the given EnigmaCrackParams struct.
 
int enigma_crack_set_max_score (EnigmaCrackParams *cfg, float maxScore)
 Set the maximum score field in the given EnigmaCrackParams struct.
 
int enigma_crack_set_target_score (EnigmaCrackParams *cfg, float targetScore)
 Set the target score field in the given EnigmaCrackParams struct.
 
int enigma_crack_set_known_plaintext (EnigmaCrackParams *cfg, const char *knownPlaintext, size_t length)
 Set the known plaintext field in the given EnigmaCrackParams struct.
 

Detailed Description

This file implements functions for cracking Enigma machine configurations using various methods such as brute force and n-gram analysis. It includes functions for loading dictionaries, scoring decrypted text, and finding potential indices in the ciphertext where known plaintext may exist.

Macro Definition Documentation

◆ _POSIX_C_SOURCE

#define _POSIX_C_SOURCE   200809L

Function Documentation

◆ enigma_crack_get_ciphertext()

const char * enigma_crack_get_ciphertext ( const EnigmaCrackParams cfg)

Get the ciphertext field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
Returns
The ciphertext field, or NULL if cfg is NULL

◆ enigma_crack_get_ciphertext_length()

size_t enigma_crack_get_ciphertext_length ( const EnigmaCrackParams cfg)

Get the ciphertext_length field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
Returns
The ciphertext_length field, or ENIGMA_FAILURE if cfg is NULL

◆ enigma_crack_get_dictionary()

const char ** enigma_crack_get_dictionary ( const EnigmaCrackParams cfg)

Get the dictionary field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
Returns
The dictionary field, or NULL if cfg is NULL.

◆ enigma_crack_get_dictionary_length()

size_t enigma_crack_get_dictionary_length ( const EnigmaCrackParams cfg)

Get the dictionary_length field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
Returns
The dictionary_length field, or ENIGMA_FAILURE if cfg is NULL.

◆ enigma_crack_get_enigma()

const Enigma * enigma_crack_get_enigma ( const EnigmaCrackParams cfg)

Get the enigma field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
Returns
The enigma field, or NULL if cfg is NULL.

◆ enigma_crack_get_flags()

int enigma_crack_get_flags ( const EnigmaCrackParams cfg)

Get the flags field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
Returns
The flags field, or ENIGMA_FAILURE if cfg is NULL

◆ enigma_crack_get_frequency_targets()

const float * enigma_crack_get_frequency_targets ( const EnigmaCrackParams cfg)

Get the frequency_targets field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
Returns
The frequency_targets field, or NULL if cfg is NULL

◆ enigma_crack_get_known_plaintext()

const char * enigma_crack_get_known_plaintext ( const EnigmaCrackParams cfg)

Get the known_plaintext field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
Returns
The known_plaintext field, or NULL if cfg is NULL

◆ enigma_crack_get_known_plaintext_length()

size_t enigma_crack_get_known_plaintext_length ( const EnigmaCrackParams cfg)

Get the known_plaintext_length field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
Returns
The known_plaintext_length field, or ENIGMA_FAILURE if cfg is NULL

◆ enigma_crack_get_max_score()

float enigma_crack_get_max_score ( const EnigmaCrackParams cfg)

Get the max_score field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
Returns
The max_score field, or ENIGMA_FAILURE if cfg is NULL

◆ enigma_crack_get_min_score()

float enigma_crack_get_min_score ( const EnigmaCrackParams cfg)

Get the min_score field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
Returns
The min_score field, or ENIGMA_FAILURE if cfg is NULL

◆ enigma_crack_get_n()

int enigma_crack_get_n ( const EnigmaCrackParams cfg)

Get the n field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
Returns
The n field, or ENIGMA_FAILURE if cfg is NULL

◆ enigma_crack_get_ngrams()

const float * enigma_crack_get_ngrams ( const EnigmaCrackParams cfg)

Get the ngrams field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
Returns
The ngrams field, or NULL if cfg is NULL.

◆ enigma_crack_get_ngrams_length()

size_t enigma_crack_get_ngrams_length ( const EnigmaCrackParams cfg)

Get the ngrams_length field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
Returns
The ngrams_length field, or ENIGMA_FAILURE if cfg is NULL

◆ enigma_crack_get_score_list()

const EnigmaScoreList * enigma_crack_get_score_list ( const EnigmaCrackParams cfg)

Get the score_list field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
Returns
The scores field, or NULL if cfg is NULL.

◆ enigma_crack_get_target_score()

float enigma_crack_get_target_score ( const EnigmaCrackParams cfg)

Get the target_score field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
Returns
The target_score field, or ENIGMA_FAILURE if cfg is NULL

◆ enigma_crack_params_new()

EnigmaCrackParams * enigma_crack_params_new ( void  )

Create a new EnigmaCrackParams structure.

This function allocates memory for a new EnigmaCrackParams structure.

Returns
Pointer to the newly created EnigmaCrackParams structure, or NULL on failure.

◆ enigma_crack_params_validate()

int enigma_crack_params_validate ( const EnigmaCrackParams cfg)

Check what capabilities the EnigmaCrackParams structure has.

This function checks if the EnigmaCrackParams structure is able to be used to perform cracking operations. The following flags are checked:

  • ENIGMA_DICTIONARY_EXISTS: The dictionary exists and is not empty.
  • ENIGMA_N_GRAMS_EXIST: The n-grams exist and are valid.
  • ENIGMA_IOC_FREQS_EXIST: The IOC frequencies exist and are valid.
  • ENIGMA_CIPHERTEXT_EXISTS: The ciphertext exists and is not empty.
  • ENIGMA_SCORE_BOUNDS_EXIST: The score bounds exist and are valid.
Parameters
cfgPointer to the EnigmaCrackParams structure.
Returns
A bitmask indicating the capabilities of the EnigmaCrackParams structure.

◆ enigma_crack_plugboard()

int enigma_crack_plugboard ( EnigmaCrackParams cfg,
float(*)(const EnigmaCrackParams *, const char *)  scoreFunc 
)

Crack the plugboard using a scoring function.

This function attempts to determine the plugboard settings used in the Enigma machine by evaluating all possible plugboard configurations and scoring the resulting plaintext using the provided scoring function.

Parameters
cfgPointer to the cracking configuration structure.
scoreFuncFunction pointer to the scoring function to use.
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure.

◆ enigma_crack_reflector()

int enigma_crack_reflector ( EnigmaCrackParams cfg,
float(*)(const EnigmaCrackParams *, const char *)  scoreFunc 
)

Crack the reflector using a scoring function.

This function attempts to determine the reflector used in the Enigma machine by evaluating all possible reflectors and scoring the resulting plaintext using the provided scoring function.

Parameters
cfgPointer to the cracking configuration structure.
scoreFuncFunction pointer to the scoring function to use.
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure.

◆ enigma_crack_rotor()

int enigma_crack_rotor ( EnigmaCrackParams cfg,
int  targetRotor,
float(*)(const EnigmaCrackParams *, const char *)  scoreFunc 
)

Crack the rotor using a scoring function.

This function attempts to determine the rotor used in the Enigma machine by evaluating all possible rotors and scoring the resulting plaintext using the provided scoring function.

Parameters
cfgPointer to the cracking configuration structure.
targetRotorThe index of the rotor to crack (0-based).
scoreFuncFunction pointer to the scoring function to use.
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure.

◆ enigma_crack_rotor_position()

int enigma_crack_rotor_position ( EnigmaCrackParams cfg,
int  rotor,
float(*)(const EnigmaCrackParams *, const char *)  scoreFunc 
)

Crack a rotor's position using a scoring function.

This function attempts to determine the starting position of the given rotor by evaluating all possible rotor positions and scoring the resulting plaintext using the provided scoring function.

Parameters
cfgPointer to the cracking configuration structure.
scoreFuncFunction pointer to the scoring function to use.
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure.

◆ enigma_crack_rotor_positions()

int enigma_crack_rotor_positions ( EnigmaCrackParams cfg,
float(*)(const EnigmaCrackParams *, const char *)  scoreFunc 
)

Crack the rotor positions using a scoring function.

This function attempts to determine the rotor starting positions of the Enigma machine by evaluating all possible rotor positions and scoring the resulting plaintext using the provided scoring function.

Parameters
cfgPointer to the cracking configuration structure.
scoreFuncFunction pointer to the scoring function to use.
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure.

◆ enigma_crack_rotors()

int enigma_crack_rotors ( EnigmaCrackParams cfg,
float(*)(const EnigmaCrackParams *, const char *)  scoreFunc 
)

Crack the rotor order using a scoring function.

This function attempts to determine the order of rotors used in the Enigma machine by evaluating all possible rotor orders and scoring the resulting plaintext using the provided scoring function.

Parameters
cfgPointer to the cracking configuration structure.
scoreFuncFunction pointer to the scoring function to use.
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure.

◆ enigma_crack_set_ciphertext()

int enigma_crack_set_ciphertext ( EnigmaCrackParams cfg,
const char *  ciphertext,
size_t  length 
)

Set the ciphertext field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
ciphertextThe ciphertext string
lengthThe length of the ciphertext string
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure

◆ enigma_crack_set_dictionary()

int enigma_crack_set_dictionary ( EnigmaCrackParams cfg,
const char **  dictionary,
size_t  length 
)

Set the dictionary field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
dictionaryThe dictionary array
lengthThe length of the dictionary array
Returns
0 on success, -1 on failure

◆ enigma_crack_set_enigma()

int enigma_crack_set_enigma ( EnigmaCrackParams cfg,
Enigma enigma 
)

Set the enigma field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
enigmaThe Enigmainstance
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure

◆ enigma_crack_set_flags()

int enigma_crack_set_flags ( EnigmaCrackParams cfg,
int  flags 
)

Set the flags field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
flagsThe flags value
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure

◆ enigma_crack_set_frequency_targets()

int enigma_crack_set_frequency_targets ( EnigmaCrackParams cfg,
float *  frequencyTargets 
)

Set the frequency targets field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
frequencyTargetsThe frequency targets array
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure

◆ enigma_crack_set_known_plaintext()

int enigma_crack_set_known_plaintext ( EnigmaCrackParams cfg,
const char *  knownPlaintext,
size_t  length 
)

Set the known plaintext field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
knownPlaintextThe known plaintext string
lengthThe length of the known plaintext string
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure

◆ enigma_crack_set_max_score()

int enigma_crack_set_max_score ( EnigmaCrackParams cfg,
float  maxScore 
)

Set the maximum score field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
maxScoreThe maximum score value
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure

◆ enigma_crack_set_min_score()

int enigma_crack_set_min_score ( EnigmaCrackParams cfg,
float  minScore 
)

Set the minimum score field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
minScoreThe minimum score value
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure

◆ enigma_crack_set_n()

int enigma_crack_set_n ( EnigmaCrackParams cfg,
int  n 
)

Set the n field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
nThe n value
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure

◆ enigma_crack_set_ngrams()

int enigma_crack_set_ngrams ( EnigmaCrackParams cfg,
float *  ngrams,
int  n,
size_t  length 
)

Set the ngrams field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
ngramsThe ngrams array
nThe n value
lengthThe length of the ngrams array
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure

◆ enigma_crack_set_score_list()

int enigma_crack_set_score_list ( EnigmaCrackParams cfg,
EnigmaScoreList scoreList 
)

Set the score_list field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
scoreListThe EnigmaScoreList instance
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure

◆ enigma_crack_set_target_score()

int enigma_crack_set_target_score ( EnigmaCrackParams cfg,
float  targetScore 
)

Set the target score field in the given EnigmaCrackParams struct.

Parameters
cfgThe EnigmaCrackParams struct instance
targetScoreThe target score value
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure

◆ enigma_dict_match()

int enigma_dict_match ( const EnigmaCrackParams cfg,
const char *  plaintext 
)

Checks if multiple words from the dictionary are present in the plaintext.

This function checks the plaintext against a dictionary of words and returns 1 if multiple words are found, otherwise returns 0.

The dictionary must be uppercase and sorted.

Parameters
cfgThe EnigmaCrackParams struct containing the dictionary and its size
plaintextThe plaintext to check
Returns
1 if multiple words are found, 0 if not, ENIGMA_FAILURE on error

◆ enigma_find_potential_indices()

int enigma_find_potential_indices ( const char *  ciphertext,
const char *  plaintext,
int *  indices 
)

Finds potential indices in the ciphertext where the known plaintext may exist.

Due to the nature of the Enigma machine, a letter cannot be encoded to itself. This function checks the ciphertext for potential indices where the given string could potentially be in the plaintext.

Parameters
ciphertextThe ciphertext to analyze
plaintextThe known plaintext string to test against the ciphertext
indicesPointer to an array (length >= length of ciphertext) to store the indices (-1-terminated)
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure.

◆ enigma_freq()

float enigma_freq ( const char *  plaintext,
int  len 
)

Calculate the frequency of characters in the plaintext.

This function calculates the frequency of each character in the plaintext and returns a score based on the frequencies.

Parameters
plaintextThe plaintext to analyze
lenThe length of the plaintext
Returns
The frequency score of the plaintext, or ENIGMA_FAILURE if the input is invalid.

◆ enigma_letter_freq()

int enigma_letter_freq ( const EnigmaCrackParams cfg,
const char *  plaintext 
)

Check if the letter frequencies in the plaintext match target frequencies within an offset.

This function checks if the frequency of each letter in the plaintext is within the specified offset of the target frequencies. If more than ten letters deviate from the target frequencies, the function returns 0 (false). Otherwise, it returns 1 (true).

Parameters
cfgThe EnigmaCrackParams struct containing the target frequencies and offset
plaintextThe plaintext to analyze
Returns
1 if over half of the letter frequencies match within the offset, 0 if not, ENIGMA_FAILURE if error.

◆ enigma_score_append()

int enigma_score_append ( EnigmaCrackParams cfg,
Enigma enigma,
const char *  plaintext,
float  score 
)

Append a score to an EnigmaScoreList.

If the scores array is full, it will be resized to double its current size.

Parameters
cfgPointer to the cracking configuration structure.
enigmaPointer to the Enigma structure representing the scored configuration.
plaintextThe plaintext corresponding to the score.
scoreThe score to append.
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure.

◆ enigma_score_flags()

int enigma_score_flags ( const EnigmaCrackParams cfg,
const char *  plaintext 
)

Get the flags for a given plaintext based on the crack configuration.

This function checks the plaintext against the criteria specified in the EnigmaCrackParams and returns a bitmask of flags indicating which criteria were met.

Parameters
cfgThe EnigmaCrackParams containing the criteria and flags.
plaintextThe plaintext to evaluate.
Returns
A bitmask of flags indicating which criteria were met, or ENIGMA_FAILURE if error.