Your experience with the older machine is probably because RC6 uses
Posted on 2002-07-31 16:33:50 by f0dder

Your experience with the older machine is probably because RC6 uses

yep, that's what i thought, too. there are a few imul instructions in my code ;)
Posted on 2002-07-31 16:39:52 by Tola
Here I made a little test with a simple algorithm, that you can change. As the program is now, it is not very secure for encryption, although it can protect your text messages from your little sister. :grin:
Posted on 2002-08-03 12:58:25 by CodeLover
I wrote rc4 wrapper code (uses microsofts implementation) and it's just for strings.

;                          Rc4.asm  -  description
;                            -------------------
;    begin                :Mon October 20 14:26:03 IDT 2004
;    copyright            :Webring (C) 2004
;    email      
; website              :
;    about                :Rc4 wrapper code based off Microsofts implementation;
;                        :currently only string example
                          ;FIXED by upb,thanks alot man

.model flat, stdcall
option casemap:none
include \Masm32\include\
include \Masm32\include\
include  \Masm32\include\
include  \Masm32\include\
includelib \Masm32\lib\kernel32.lib
includelib  \Masm32\lib\user32.lib
includelib  \Masm32\lib\advapi32.lib

HandleError proto :DWORD

ZeroTerm MACRO cSize:REQ
              mov ecx,cSize
              mov byte ptr , 0
;All const's have been takin out of wincrypt.h
ALG_CLASS_HASH          equ 32768
ALG_TYPE_ANY            equ 0
ALG_TYPE_BLOCK          equ 1536
ALG_TYPE_STREAM          equ 2048
ALG_SID_RC2              equ 2
ALG_SID_RC4              equ 1
ALG_SID_MD5              equ 3
PROV_RSA_FULL            equ 1
CRYPT_NEWKEYSET          equ 8h

MS_PROV    db "Microsoft Base Cryptographic Provider v1.0",0 ;my box not support enhanced =\
Cryptkey  db "Joshua",0 ; fyi is #1 most used backdoor pass of *all time ;)
mydata    db "UbEr 133Ness",0
dTitle    db "After Decrypted",0
eTitle    db "After Encrypted",0
rTitle    db "Before Encrypted",0

;error handling
CACHerror    db "CryptAcquireContext",0
CCHerror      db "CryptCreateHash",0
CHDHerror    db "CryptHashData",0
CDKHerror    db "CryptDeriveKey",0
CDHHerror    db "CryptDestroyHash",0
GAHerror      db "GlobalAlloc",0
GLHHerror    db "GlobalLock",0
CEHHerror    db "CryptEncrypt",0
CDEHHerror    db "CryptDecrypt",0
GUHHerror    db "GlobalUnlock",0
CDEKHHerror  db "CryptDestroyKey",0
GFHHerror    db "GlobalFree",0
KeyContainerName db "leetcrypt", 0

lKey          dd ?
lHash        dd ?
bufL          dd ?
dataL   dd ?
crypted   dd ?
decrypted   dd ?
OldKeyL      dd ?
NewBuf        dd ?
NewBuf2      dd ?
cspHAND      dd ?
contain      db ?
cryptedSize   dd ?
decryptedSize dd ?
tight db 512 dup(?)

invoke MessageBox, NULL,addr mydata, addr rTitle,MB_ICONINFORMATION

invoke lstrlen, addr mydata
mov cryptedSize, eax

invoke Rc4, addr Cryptkey, addr mydata, 1, addr cryptedSize ;encrypt
mov crypted, eax
ZeroTerm(cryptedSize)          ; zero terminate for MessageBox   

invoke MessageBox, NULL, crypted, addr eTitle, MB_ICONINFORMATION
push cryptedSize
pop decryptedSize

; [====================================]
invoke Rc4,addr Cryptkey, crypted, 0, addr decryptedSize ;decrypt
mov decrypted, eax
ZeroTerm(decryptedSize)        ; zero terminate for MessageBox

invoke MessageBox, NULL, decrypted, addr dTitle, MB_ICONINFORMATION
invoke ExitProcess,0

;if an error occures a MessageBox with the api function name as the title and an description will appear
Rc4 proc lpKey, lpSource, lpType, lpSize
invoke CryptAcquireContext, addr cspHAND, NULL, NULL, PROV_RSA_FULL, 0 ;Get handle to the default provider.
.if eax!=TRUE
invoke HandleError,addr CACHerror

invoke CryptCreateHash,cspHAND,CALG_MD5,0,0,addr lHash ;Create a hash object
.if eax!=TRUE
invoke HandleError,addr CCHerror

invoke lstrlen,lpKey
mov OldKeyL,eax

invoke CryptHashData,lHash, lpKey,OldKeyL, 0
.if eax!=TRUE
invoke HandleError,addr CHDHerror

invoke CryptDeriveKey,cspHAND,CALG_RC4, lHash, 0 ,addr lKey
.if eax!=TRUE
invoke HandleError,addr CDKHerror

invoke CryptDestroyHash,lHash
.if eax!=TRUE
invoke HandleError,addr CDHHerror

;invoke lstrlen, lpSource
mov     esi, lpSize
mov eax, dword ptr
mov bufL, eax
add bufL, 129 ; just to be sure

invoke GlobalAlloc,GMEM_MOVEABLE,bufL
.if eax==NULL
invoke HandleError,addr GAHerror

mov NewBuf,eax

invoke GlobalLock,NewBuf
.if eax==NULL
invoke HandleError,addr GLHHerror
mov NewBuf2,eax

; copy data to be encrypted
mov esi, lpSource
mov edi, NewBuf2
mov ecx, lpSize
mov ecx, dword ptr
rep movsb

cmp lpType,0  ;Check whether to en/decrypt
je @F

invoke CryptEncrypt,lKey, 0, 1, 0, NewBuf2, lpSize, bufL
.if eax!=TRUE
invoke HandleError,addr CEHHerror
jmp cleanup


invoke CryptDecrypt,lKey, 0, 1, 0, NewBuf2, lpSize
.if eax!=TRUE
invoke HandleError,addr CDEHHerror


invoke CryptDestroyKey,lKey
.if eax!=TRUE
invoke HandleError,addr CDEKHHerror

; write other cleanup stuff urself

mov eax, NewBuf2
Rc4 endp

;Handle error
HandleError proc lpTitle:DWORD
shl ecx,10           
lea edx, MsgBuf               
invoke GetLastError                     
invoke MessageBox, NULL, MsgBuf,lpTitle,MB_OK or MB_ICONSTOP
invoke LocalFree,MsgBuf
invoke ExitProcess,0
HandleError endp

end start

I've tried comrads pure code rc4 example on various versions of windows, but couldn't get it to work. Btw f0dder why don't you lay off the constant follow up attacks at hutch everytime the man posts somthing.
Posted on 2005-04-18 11:23:58 by Webring
I don't know a great deal about encryption, but it's a lot of math.

Essentially, encryption algorithms work on computationally hard problems.  I'm not familiar with elliptic curves, so I don't know the math behind those (though I do want to learn!).  RSA, for example, is strong because the only way to break it (as far as anyone knows) is to factor a very large integer, which is no easy task.  Others use the difficulty of finding discrete logarithms, etc.

That doesn't always mean basing an encryption scheme on computationally hard problem will work.  For instance, there was an encryption algorithm based on the knapsack problem, which is NP complete in the general case.  However the encryption was found to be breakable (if I recall, due to the fact it used a superincreasing set of weights, so it wasn't a general case).
Posted on 2005-04-21 11:52:57 by Miko
Encryption (including cryptographic hashes) is fascinating, and the attacks invented to break algorithms are done by some very clever heads.

I hope the following isn't in contradiction with the board rules. It's meant as some things to consider when implementing encryption algorithms, so you don't get the stuff wrong.

MD5, a widely used secure hash algorithm, has received a lot of analysis because the use is so widespread - including guarding unix passwords on a lot of systems. There were some attacks, mostly theoretic though... and then came the rainbow tables (google around) - these make attacks *practical*, although they require a lot of memory and disk space for the tables.

The TEA encryption algorithm had a number of weak implementations - I think it wasn't until the 3rd try they "got it right". It's still not the most secure algorithm, but it's small and simple. The SafeDisc protection system used TEA encryption - but it had a number of flaws in the way it used it. Iirc, it only used half the possible keysize, and that fact combined with the knowledge that PE sections aligned to peheader.filealign (and padded with zero-bytes), it was possible to quickly bruteforce the key and remove the encryption (there were other methods as well, but the interesting one in this context is of course the cryptographic attack).

RSA is generally pretty annoying to factor, because of the use of big primes. There are a number of ways to break it, though... there's been a lof of problems with weak generation algorithms used - basically if a software user has seeded the random number generator with time(NULL) (ie, the system time), and the RNG being used is known (like, if a well-known cryptographic library has been used), the attacker has some idea which time range the key has been generated in, and can use this information to attack only a subset of the possible keys. This way RSA-1024 (iirc) has been broken, I believe the private keys for signing asprotect programs was found for some version? The method used when a key can't be factored within reasonable time, is to patch the key in the executable, and write a new key generator using this set of {private, public} key.

RC4 has had some attacks too. The algorithm has been used in things like SSL, and has been broken.

The latest appliance of breaking hashes, will be used to pollute the edonkey2000 network. Rather than foiling pirates by movie/game companies releasing a lot of fake releases (which can be identified on "release verifier" sites, and waste a lot of bandwidth), they can upload bogus chunks *with matching hashes* - this way the fake releases are very hard to detect, and you will end up with a corrupted download without really being able to tell what parts are wrong. This is of course fixable by the p2p community by moving to stronger hashes, which will enevitably happen.

By the way, have a look at this URL:
Posted on 2005-04-21 15:38:14 by f0dder