ASM lib with crytographic, hash, and checksum algorithms

For everything that's not in any way related to PureBasic. General chat etc...
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

ASM lib with crytographic, hash, and checksum algorithms

Post by gnozal »

Could be interesting (not tested).
Description:

Functions for number of crytographic, hash, and checksum algorithms.
Hashes: md4, md2, rmd128, rmd160, rmd256, rmd320, sha0, sha1, sha256, sha384, sha512, tiger, whirlpool haval, md5
Checksums: crc32, crc16, adler
Ciphers: tea, xtea, rc2, rc4, rc5, rc6, blowfish, 3-Way rijndael, DES

Written in ASM, source code included.
Homepage : http://drizz.t35.com
Download : http://drizz.t35.com/files/cryptohash.rar
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

I have tried using this library both directly (in C with MS Visual Studio 2005) and also indirectly - but not much of a success. And I havent found a way how to contact the author!
This is what I have done - might help somebody
BUT
I have found a problem with the encryption routines
It seems they only encrypt up to a particular size.
Has anybody tried to use it/them ? or has any feedback ? or maybe I am doing some stupid mistake ? (wouldnt be the first and I suspect neither will it be the last alas)

Code: Select all

; HASHES
; ======

#MD5_DIGESTSIZE       = (128/8)
#MD4_DIGESTSIZE       = (128/8)
#MD2_DIGESTSIZE       = (128/8)
#RMD128_DIGESTSIZE    = (128/8)
#RMD160_DIGESTSIZE    = (160/8)
#RMD256_DIGESTSIZE    = (256/8)
#RMD320_DIGESTSIZE    = (320/8)
#SHA0_DIGESTSIZE      = (160/8)
#SHA1_DIGESTSIZE      = (160/8)
#SHA256_DIGESTSIZE    = (256/8)
#SHA384_DIGESTSIZE    = (384/8)
#SHA512_DIGESTSIZE    = (512/8)
#WHIRLPOOL_DIGESTSIZE = (512/8)
#TIGER_DIGESTSIZE     = (192/8)


 Import "cryptohash.lib"
   
  md5init () As "_MD5Init@0"
  md5Update ( text$, len.l ) As "_MD5Update@8"
  md5Final () As "_MD5Final@0"
  HexEncode ( text$, type.l, Out$) As "_HexEncode@12"
  HexDecode ( text$, out$ ) As "_HexDecode@8"
    
  rc6init ( text$, len.l ) As "_RC6Init@8"
  rc6encrypt ( in$, out$ ) As "_RC6Encrypt@8"
  rc6decrypt ( in$, out$ ) As "_RC6Decrypt@8"	  
  
  xteainit ( text$, type.l ) As "_XTEAInit@8"
  xteaencrypt ( in$, out$ ) As "_XTEAEncrypt@8"
  xteadecrypt ( in$, out$ ) As "_XTEADecrypt@8"  
  
  blowfishinit    ( text$, len.l ) As "_BlowfishInit@8"
  blowfishencrypt ( in$, out$ ) As "_BlowfishEncrypt@8"
  blowfishdecrypt ( in$, out$ ) As "_BlowfishDecrypt@8"
  
  threewayinit    ( text$ ) As "_ThreeWayInit@4"
  threewayencrypt ( in$, out$ ) As "_ThreeWayEncrypt@8"
  threewaydecrypt ( in$, out$ ) As "_ThreeWayDecrypt@8"
                                                   
 EndImport


;key$ = "KeyUsed To Encrypt _+=)( 2000 Needs To Be Very Very Long &^$#@ Especially Since We Will Not Use *() it All aqnd we will also add some garbage at the end"
key$ = "Key Used To Encrypt the various techniques"
text$ = "the string to be encoded man"
out1$ = Space ( 256 )
out2$ = Space ( 256 )
len.l = Len ( key$ )


Debug "===="
Debug "3Way"
Debug "===="


len = Len ( key$ )
;len = 10
threewayinit ( key$ )
Debug "Key: " + key$
threewayencrypt ( text$, out1$ )
Debug "out1: " + out1$

threewaydecrypt ( out1$, out2$ )
Debug "out2: " + out2$



Debug "========"
Debug "BlowFish"
Debug "========"


len = Len ( key$ )
;len = 10
blowfishinit ( key$, len )
Debug "Key: " + key$
blowfishencrypt ( text$, out1$ )
Debug "out1: " + out1$

blowfishdecrypt ( out1$, out2$ )
Debug "out2: " + out2$

Debug "==============="
Debug "MD5 / HexEncode"
Debug "==============="

md5Init ()
md5Update ( key$, len )
*ptr = MD5Final ()
temp.s = PeekS ( *ptr )
Debug "temp: " + temp

HexEncode ( Key$, len, out1$ )
Debug "out1: " + out1$

Debug "==="
Debug "rc6"
Debug "==="


test.s = "LetsSeeIfThisWorks00"

rc6init    ( test, Len (test) )
rc6encrypt ( "My test encryption too", out1$ )
Debug "out1: " + out1$
rc6decrypt ( out1$, out2$ )
Debug "out2: " + out2$
Debug "Key Again: " + key$

Debug "===="
Debug "XTEA"
Debug "===="


len = 8
xteainit ( key$, len )
xteaencrypt ( text$, out1$ )
xteadecrypt ( out1$, out2$ )

Debug "out1: " + out1$
Debug "out2: " + out2$

cheers

KingLestat
Last edited by kinglestat on Thu Feb 01, 2007 8:30 pm, edited 1 time in total.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

@KingLestat

please use code-tags...
oh... and have a nice day.
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

how do you use these code blocks ? It is not on the FAQ..so I suggest you add a topic on the FAQ too about it

cheers

KingLestat
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

The code tags :

[code]your code[/code]
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

...you can add it pressing the button labelled "Code" on the "Post a reply"-page...

when you have already some code in the post, mark the whole code and press the button,
then both tags start + end will be added around the marked text.
(same applies to all Tag-Buttons)
oh... and have a nice day.
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

thanks

code test

Code: Select all

debug "Hello World"
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

fine.

now click on "edit" at your above post, mark the complete code and TAG it... ;)
oh... and have a nice day.
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

you know I never thought I could modify my own post
I am way out stuck in the dark ages!
thanks for the help

but anybody actually try it out?!!!
My actual question ?
PBUser
User
User
Posts: 20
Joined: Mon Aug 20, 2007 6:03 pm
Location: Germany

Post by PBUser »

404 Not Found.

Could someone reup this library please?

Thanks!
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
JCV
Enthusiast
Enthusiast
Posts: 580
Joined: Fri Jun 30, 2006 4:30 pm
Location: Philippines

Post by JCV »

I have compiled a lib with all hash functions before.
http://www.purebasic.fr/english/viewtop ... 21&start=0

Thanks for the the link. :D
I'll post a working lib and combine it to my library later.

edit:
The hash functions seems to work fine. Doing on encryption routines. Im having trouble on unicode.

@kinglestat
It work that way because these are block ciphers.
If block size for example 128 bits (16 bytes) and yours is 18 bytes, you must pad it. Etc. Adding bytes etc.

Worth to read
http://en.wikipedia.org/wiki/Block_ciph ... _operation

[Registered PB User since 2006]
[PureBasic 6.20][SpiderBasic 2.2]
[RP4 x64][Win 11 x64][Ubuntu x64]
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

yes and figured that out some time ago
but had forgotten the post
They have all become part of my libs...in C and PB
Quite fast I have to say

cheers
I may not help with your coding
Just ask about mental issues!

http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
SebastianJu2
New User
New User
Posts: 2
Joined: Wed Jun 08, 2011 9:37 pm

Re: ASM lib with crytographic, hash, and checksum algorithms

Post by SebastianJu2 »

I downloaded the DE-File but I dont have a clue how i could use it to hash SHA256 with it. Can someone please explain how to implement it?

Thanks!
Sebastian
Post Reply