User Tools

Site Tools


battcrypt

battcrypt

Designer

  • Steve Thomas

Download Submission

Strengths

  • Anti-GPU based off Blowfish

Pseudocode

# *** Functions/symbols ***
# **                         Exponential
# %                          Modulus
# ||                         Concatenate two strings
# ^                          XOR two strings
# sha512                     Calculates a SHA512 of a string
# blowfish_init_448_bit_key  Initializes blowfish with a 448 bit key
# blowfish_encrypt_cbc       This is a running CBC (ie the last block of the
#                              previous call is the IV for the next call)
# truncate(string, N)        Truncates a string to N bytes
# zeros(N)                   Creates an N byte string of zeros
# last_64_Bits(string)       Gets last 64 bits of a string
# BE_64_TO_STR               Converts a 64 bit big endian integer to an 8 byte string
# STR_TO_BE_64               Converts an 8 byte string to a 64 bit big endian integer
 
 
# *** Inputs ***
string   password
string   salt
integer  t_cost
integer  m_cost
integer  outlen
 
 
# *** Algorithm ***
t_cost_1       = t_cost % 2 ** 16
t_cost_2       = floor(t_cost / 2 ** 16)
t_cost_main    = 2 ** floor(t_cost_1 / 2) * ((t_cost_1 % 2) + 2)
#              = 2, 3, 4, 6, 8, 12, ...
t_cost_upgrade = floor(2 ** floor((t_cost_2 - 1) / 2) * (3 - (t_cost_2 % 2)))
#              = 1, 2, 3, 4, 6, 8, 12, ... (Note floor(-1 / 2) = -1)
mem_size       = 4 * 2 ** m_cost
 
key = sha512(sha512(salt) || password))
for u = 0 to t_cost_upgrade - 1
	# Initialize blowfish
	blowfish_init_448_bit_key(truncate(key, 56), iv:zeros(8))
 
	# Initialize data
	data = sha512(BE_64_TO_STR( 0) || key) ||
	       sha512(BE_64_TO_STR( 1) || key) ||
	       ...
	       sha512(BE_64_TO_STR(31) || key)
 
	# Initialize mem
	for i = 0 to mem_size - 1
		data = blowfish_encrypt_cbc(data)
		mem[i] = data
	data = blowfish_encrypt_cbc(data)
 
	# Main loop
	for i = 0 to t_cost_main - 1
		for j = 0 to mem_size - 1
			r = STR_TO_BE_64(last_64_Bits(data)) & (mem_size - 1) 
			mem[j] = blowfish_encrypt_cbc(data ^ mem[j] ^ mem[r])
			data = data ^ mem[j]
 
	# Finish
	key = sha512(sha512(data || key))
	key = truncate(key, outlen) || zeros(64 - outlen)
 
return truncate(key, outlen)
battcrypt.txt · Last modified: 2014/05/26 07:48 (external edit)