|
PowerBASIC Forums
![]() Programming
![]() Public key cryptography (Page 1)
|
This topic is 2 pages long: 1 2 |
next newest topic | next oldest topic |
| Author | Topic: Public key cryptography |
|
Wayne Diamond Member |
Mid$(TextStr$, i, 1) = CHR$(ASC(Mid$(TextStr$, i, 1)) XOR 13) That's a good (by good, i mean simple!) example of a symmetric cipher, symmetric meaning the same key (in this case xor 13) can be used to both encrypt and decrypt data. Does anyone have any simple examples of ASSYMETRIC/"public-key" encryption? Emphasis on simple im more looking into the theory than actual cipher strength, so the simpler the better, but this one is taxing my brain ![]() ------------------ IP: Logged |
|
Aldo Cavini Member |
The following is from an old DOS program. I don't know whether it is an ASSYMETRIC/"public-key" encryption method, since I "invented" it from scratch - at least it is guaranteed it works!
I needed Decrypt to be the fastest of the two. It simply gets a char, multiplyes it for a constant (constant must be a prime number), adds it an offset and truncates it to an 8 bit value. The other sub somehow performs the reverse. ------------------ [This message has been edited by Aldo Cavini (edited July 31, 2001).] IP: Logged |
|
Scott Turchin Member |
I don't know if this falls under it or not, since it pretty much uses one key....
------------------ IP: Logged |
|
Tim Wisseman unregistered |
This is how one form of public key encryption works. I run my make key program: MakeKey I have a public key of 13,78 and a private key of 78,13 My friend Bob, wants to send me a message the text of which is ENCRYPT "h" , 13, 78 Now Bob sends me the message, but sneaky Bill intercepts ENCRYPT 179 , 13, 78 DECRYPT 179 , 13, 78 Sneaky Bill has been foiled! I get the message and decrypt it using my private key: DECRYPT 179 , 78, 13 Oh yes! "h" I will get on it at once! The power of public key encryption is in the vast amount I bet you can figure out what the relationship of my public The CIA might intercept my message and just run my SuperKeyCracker2000 13, 78 Drats! The CIA can now read my secret messages! I think I might Now some source code to play with: DIM sMess AS STRING '// The message we are sending is just "h" '// Public Key = 13 and 78 '// Your secret message (It will be 179)
[This message has been edited by Tim Wisseman (edited August 01, 2001).] IP: Logged |
|
Wayne Diamond Member |
Aldo, Scott, those are both symetric algorithms - to decrypt the encrypted data, you just reapply the same algorithm with the same key. Its easier to understand in a diagram -
but with Assymetric encryption, you have one key to encrypt, and a different key to decrypt. Easy in concept, but what's got me confused is the actual workings of the algorithm, and Timm i think you've hit the nail on the head there! Many thanks kind sir for taking the time to write that excellent description (for some reason I was getting nowhere reading RSA documentation )Ive printed out your post so i can be re-read it tonight before my eyes give in to sleep The reason why I asked is because a shareware program of mine which uses symetric encryption on its keyfiles was recently cracked - these guys (a 31337 Russian outfit, possibly one of Semens mates? ) made a KEYGEN! And the keys are based on the PC1 128-bit encryption algo (not a simple serial that can be sniffed from memory), but these guys wrote a keygen no worries so that was a big wake-up call for me. I was really impressed and contacted the cracker to both congratulate and query him (you can go a long way if you speak nicely to them), and we've been exchanging emails, he's a very polite bloke (and needless to say, very confident in himself) and it was he who suggested asymetric encryption as a means of slowing down crackers. He also suggested building in checks to the keyfile that aren't compiled. When the keyfile is cracked, uncomment another check in your code. I feel totally defeated though, it really is pointless even building in any form of protection when there is nothing physically stopping smart guys like this from disassembling your code. Compiled code reads like a book to them, it's kinda scary... ![]() Thanks again, Wayne ------------------ IP: Logged |
|
Wayne Diamond Member |
Here's some of what the cracker had to say, pasted here so others can get into the mind of a cracker: (FWIW: The program is a 2mb executable compiled in VB6, compressed down to 600kb with ASPack, and has a lot of built in protection code, anti-softice etc)
And when I asked him about encrypting the already-encrypted keyfiles: Once the algorythm reversed, and knowing I can used any key to encrypt a keyfile since it's shipped with the keyfile, the only things I have to do are: The mind boggles... ![]() [This message has been edited by Wayne Diamond (edited August 01, 2001).] IP: Logged |
|
Tom Hanlin Member |
As I recall it, "symmetric" does not mean that the same key is used both for encryption and decryption, but that the same algorithm can be used both for encryption and decryption-- that is, if encoded$ = encrypt$(plaintext$, password$) Then plaintext$ = encrypt$(encoded$, password$) ...but possibly there are other meanings for the term. It is not really possible to make a key-protected program that can't be broken. ------------------ IP: Logged |
|
Wayne Diamond Member |
Tom, very true, but the more time it takes them to crack it the better so personally im willing to spend a few days implementing protection into my program, it buys time and narrows down the type of people who can crack it to the eliteists and thats good enough for me . You're dead right though, and to be honest with you Im not sure if there's anything that these guys couldnt crack. In a way I have to admire them for that, it's a true talent - until last week my definition of 'reversing' was putting cold pizza in a microwave.Timm, your algorithm (and all variations i could think of in my head) can all be cracked simply by reversing the algorithm. The private key would also be a reverse of the public key, so if private key is 12345, the public key would be 54321, regardless of how you implement the algorithm, so from that I'd assume that, upon realisation that the algorithm is assymetric or whatever you want to call it, first they'd try reversing the algorithm and trying that, before trying any other more complicated methods... so your code could possibly be described as pseudo-assymetric? ![]() So, this is the challenge! Can you think of an algorithm that would use private and public keys that are of seemingly no relation? eg, 12345 and 59315 And, can that algorithm be directly reversed? I'll admit to defeat already on this, as much as ciphers, cryptography and cryptanalysis fascinate me maths has never been my forte ![]() ------------------ IP: Logged |
|
Tim Wisseman unregistered |
Okay, just a little bit more complex. How about: DIM sMess AS STRING '// The message we are sending is just "h" a = 112 XOR a
'// Private Key = 78 And 13 i = (i - a) MOD 255 ------------------ IP: Logged |
|
Wayne Diamond Member |
*CH-CHING!* We have a winner! So both the keys are unique and seemingly of no relation, AND the encryption and decryption routines are different and can't be reversed... I'm impressed!! Even more impressed that the code is still so relatively simple, even I can get my head around it ![]() Thanks again so much for that Tim, that's pretty much exactly what I wanted to know, I'll be able to take the training wheels off and ride my own assymetric cipher now ![]() ------------------ IP: Logged |
|
Tim Wisseman unregistered |
I have a reg code system that has kept the Russian crackers confused for over 2 years now. There is how the system works: The user enters the reg code in to the program: It looks something like this: EE4R877 WZA3JUU GP86BYU 3RGDDYT TFEK8L7 19 To verify the reg code is good I have my program I then mask half the bits at random and use whats left and The hashing code is stread out in over 20 places in my program in In over 50 places the program does a quick check of the hash The bottom line is you can not make a all powerful key generator You can not crack an algorithm that was never I have the added bonus of having my programs exchange data with To date the only ones that have made fake keys have been ------------------ IP: Logged |
|
Wayne Diamond Member |
Or we could get Semen to go around and beat them up? eg. Brute force ![]() Thanks again Timm, Ive printed that out also for a re-read before I go to sleep, fascinating stuff - you're right about the part about crackers not being able to disassemble encrypted code, im looking into that also. (Time to get the dust off my flowchart program )------------------ IP: Logged |
|
Trevor Lane Member |
None of those algo's really count as public key cryptographs. The reason is that two things need to be made public. That is the Public Keys and the algorythm that you want the other party to use to encrypt the message. Given the public keys and the encryption algorythm in the examples PGP uses large prime factorials, due to the fact that it would take If you are interested in how they do it follow this link regards ------------------ IP: Logged |
|
Rodney Wirtz Member |
I recently read a book titled 'Hacker Attach!' by Richard Mansfield. In his book, he presented a private key system that encrypted Thank you to those that reply! Rodney Wirtz ------------------ IP: Logged |
|
Wayne Diamond Member |
Trevor, thanks for that link... it looks fairly straight-forward - you probably couldnt find a better page explaining it than that, but its still out of my league! I challenge anyone to make a PB/CC version of that blokes example algorithm posted at that URL it seems to be a true PK crypt------------------ IP: Logged |
This topic is 2 pages long: 1 2 All times are EasternTime (US) | next newest topic | next oldest topic |
![]() |
|
Copyright © 1999-2005 PowerBASIC, Inc. All Rights Reserved.