Implement DES stuck

Questions about programming languages and debugging
Post Reply
User avatar
Stavros
ΜΟΛΩΝ ΛΑΒΕ
ΜΟΛΩΝ ΛΑΒΕ
Posts: 1098
Joined: 02 Jan 2006, 17:00
18
Location: Mississippi, U.S.A.

Implement DES stuck

Post by Stavros »

Since we don't have a crypto board (and no one is our crypto guru) I posted this here. Even if no one answers it.

Onward. So I've been looking for a CUDA DES library (preferably bitslice implementation), since there are no libraries out there I figure I'm gonna have to implement it myself. Having no background in cryptography I decided on first implementing standard DES and then moving on to bit slicing once I understand standard DES. One cannot run without first crawling. Therefore, I went in search of a how-to guide for implementing standard DES. Thankfully someone wrote a guide. Unfortunately step one has me confused. So they say there's supposed to be a key generated or inserted for the block cypher (DES) to use on the plaintext (password). The problem is that the php script** that generates a the DES hash only takes a password and salt (generated from the password), so I don't know if the password is the key or what. So my question is, is the password/plaintext the key?

A basic intro to block cypers and DES

**For reference here's the script in it's entirety:

Code: Select all

<?php
function hashtrip($input){
    $input = stripslashes($input);
    $trip = $input;
    if(preg_match("##", $input)){
        $trip = str_replace("#", "", $input);
    }
    if((function_exists('mb_convert_encoding'))){
        mb_substitute_character('none');
        $recoded_cap = mb_convert_encoding($trip, 'Shift_JIS', 'UTF-8');
    }
    $trip = (($recoded_cap != ) ? $recoded_cap : $trip);
    $salt = substr($trip.'H.', 1, 2);
    $salt = preg_replace('/[^\.-z]/', '.', $salt);
    $salt = strtr($salt, ':;<=>?@[\]^_`', 'ABCDEFGabcdef');
    $output = substr(crypt($trip, $salt), -10);
    return $output;
}
?> 
To note is the second to last line crypt only takes two parameters (password [aka $trip] and salt).

EDIT: Nix everything I just said. Okay so Unix crypt() is NOT the same thing as DES encryption. Crypt() is a cryptographic hash function. So that means implementing either crypt.c or going through PHP source code and finding crypt.c.

User avatar
Gogeta70
^_^
^_^
Posts: 3275
Joined: 25 Jun 2005, 16:00
18

Re: Implement DES stuck

Post by Gogeta70 »

Sorry, i don't have an answer for you. I think this would go better in the programming forum, so i'll move it there. If anyone disagrees, feel free to move it back.
¯\_(ツ)_/¯ It works on my machine...

User avatar
DNR
Digital Mercenary
Digital Mercenary
Posts: 6114
Joined: 24 Feb 2006, 17:00
18
Location: Michigan USA
Contact:

Re: Implement DES stuck

Post by DNR »

you are correcting in your thinking - how secure is the crypto method?

using just a password and a salt to create a key alone makes is open to reverse engineering, the salts can be figured out or predicted, a list of plaintext passwords can be fed into the system to find keys.

using a crypto method that uses an algoritum to creates a unique key with salt, without using the password as a factor in creating the key, is harder to predict or reverse.

These are the differences in the theories in crypto, pseudo-random generation algorithm, shrinking generators, initialization vector (IV), and so on.

DNR
-
He gives wisdom to the wise and knowledge to the discerning. He reveals deep and hidden things; he knows what lies in Darkness, and Light dwells with him.

Post Reply