473,378 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Generate Key using Cipher Block Chaining MAC

I want to encrypt the ASCII message using Cipher Block Chaining MAC and generate the 8 byte key.How can i achieve this?
Thanks:
Danish Majid
May 21 '07 #1
20 6005
Plater
7,872 Expert 4TB
http://en.wikipedia.org/wiki/CBC-MAC
May 21 '07 #2
RedSon
5,000 Expert 4TB
I want to encrypt the ASCII message using Cipher Block Chaining MAC and generate the 8 byte key.How can i achieve this?
Thanks:
Danish Majid
The document titled ISO/IEC 9797-2:2002 describes 3 algorithms you can use to create this. The document costs money but you can see if your local library or university library can get a copy for you.
May 21 '07 #3
Thanks for the reply but i implement CBC MAC using vb.net and generate 8 byte key through applying CBC MAC on the whole message. Do you know any website link/article where i can find source code for CBC MAC using vb.net because i can not find any code for CBC MAC in google.
Thanks:
Danish Majid
May 22 '07 #4
RedSon
5,000 Expert 4TB
Thanks for the reply but i implement CBC MAC using vb.net and generate 8 byte key through applying CBC MAC on the whole message. Do you know any website link/article where i can find source code for CBC MAC using vb.net because i can not find any code for CBC MAC in google.
Thanks:
Danish Majid
Microsoft already implements this method. http://msdn2.microsoft.com/en-us/library/aa382459.aspx
You can use their CryptoAPI.
May 22 '07 #5
The example described in this website used for encrypting data but i want to generate 8 byte key in output through applying CBC MAC to whole message.
suppose sample message is 642 ASCII characters
message=000542200000278945460202802026302002488987 12120......
the key generate by applying CBC MAC through this message is
key=24598762

this is my requirement to generate 8 byte key by applying CBC MAC to whole message.

How can i implement this in vb.net ? because i can only find code for encrypting message.
Thanks:
Danish
May 23 '07 #6
RedSon
5,000 Expert 4TB
The example described in this website used for encrypting data but i want to generate 8 byte key in output through applying CBC MAC to whole message.
suppose sample message is 642 ASCII characters
message=000542200000278945460202802026302002488987 12120......
the key generate by applying CBC MAC through this message is
key=24598762

this is my requirement to generate 8 byte key by applying CBC MAC to whole message.

How can i implement this in vb.net ? because i can only find code for encrypting message.
Thanks:
Danish
I don't know how to do it in VB but if C++ you would be looking for these functions: http://msdn2.microsoft.com/en-us/library/aa379908.aspx

Hopefully that will put you on the right path to finding the right libraries for VB
May 23 '07 #7
RedSon
5,000 Expert 4TB
I don't know how to do it in VB but if C++ you would be looking for these functions: http://msdn2.microsoft.com/en-us/library/aa379908.aspx

Hopefully that will put you on the right path to finding the right libraries for VB
Actually I found something that will help you better:
http://msdn2.microsoft.com/en-us/library/6yxzeb7e.aspx
May 23 '07 #8
Still i can not find solution to my problem on generating 8 byte hex key by applying CBC MAC to whole message using vb.net.
Any one can help me out?
May 24 '07 #9
Plater
7,872 Expert 4TB
I am still not sure what you are after, so I'll breakdown some parts

*You receive a message of 642ascii characters.
Is this the real message or an already encrypted message?

*You want to generate an 8byte DECRYPTION key for that message.
Now if the message was already encrypted, I don't think you can determine it's decrypting key just by looking at it, that kinda defeats the purpose don't you think? If the message is plain and you want the key that could be used to decrypt it once it's encrypted, then encrypt it and view the key that was used. Actually I think you can make up whatever key you want and use it to encrypt it.


But I always did bad at cryptology in school.
May 24 '07 #10
RedSon
5,000 Expert 4TB
I am still not sure what you are after, so I'll breakdown some parts

*You receive a message of 642ascii characters.
Is this the real message or an already encrypted message?

*You want to generate an 8byte DECRYPTION key for that message.
Now if the message was already encrypted, I don't think you can determine it's decrypting key just by looking at it, that kinda defeats the purpose don't you think? If the message is plain and you want the key that could be used to decrypt it once it's encrypted, then encrypt it and view the key that was used. Actually I think you can make up whatever key you want and use it to encrypt it.


But I always did bad at cryptology in school.
I took it to mean that the OP wants to create a signature key. A two way hash of the message to compare its authenticity. In any case, the links provided do show how to encrypt a message, decrypt a message, and create a hash of a message.
May 24 '07 #11
The 642 ASCII Characters are in Simple Plain Text and i want to generate 8 Byte key on applying CBC MAC to whole message. I dont know how to achieve this in vb.net?
May 25 '07 #12
RedSon
5,000 Expert 4TB
The 642 ASCII Characters are in Simple Plain Text and i want to generate 8 Byte key on applying CBC MAC to whole message. I dont know how to achieve this in vb.net?
What do you mean "create key"? You want to make the ASCII characters your key to use to encrypt data? Or do you want to create some kind of message digest or crytographic signature against the 642 ASCII Characters?

If you want to do the latter the link I provided in my prevoius post links directly to an article on MSDN as to how to Generate Signatures. It provides the VB code right there for you to look at. If you want to encrypt or decrypt data given a 642 ASCII Character key then right above where that page is on MSDN lists other Cryptograpic Tasks on how to Encrypt and Decrypt Data.

When you say "generate an 8 byte key" that means you want to create an 8 byte message digest (hash) or an 8 byte digital signature.
May 25 '07 #13
Hi,

I need to calculate the Cryptographic checksum using ISO/IEC 9797-1 MAC
algorithm with cipher block chaining MAC. The resultant MAC length must be 8 bytes.
As a sample, the data I am working on now is:
Data = '72C29C2371CC9BDB65B779B8E8D37B29ECC154AA56A8799FA E2F498F76ED92F2'
Kmac = '7962D9ECE03D1ACD4C76089DCE131543'


Resultant MAC[Kmac](Data)='53265320' (I want to know how to get
to this value using vb.net).
I search this on google but no success for the last 1 week.
Any code on urgent basis?
May 29 '07 #14
RedSon
5,000 Expert 4TB
Hi,

I need to calculate the Cryptographic checksum using ISO/IEC 9797-1 MAC
algorithm with cipher block chaining MAC. The resultant MAC length must be 8 bytes.
As a sample, the data I am working on now is:
Data = '72C29C2371CC9BDB65B779B8E8D37B29ECC154AA56A8799FA E2F498F76ED92F2'
Kmac = '7962D9ECE03D1ACD4C76089DCE131543'


Resultant MAC[Kmac](Data)='53265320' (I want to know how to get
to this value using vb.net).
I search this on google but no success for the last 1 week.
Any code on urgent basis?
This is the MSDN article about how to generate a cryptographic hash also known as a checksum.

http://msdn2.microsoft.com/en-us/lib...6k(vs.80).aspx

You will have to do some research to find out if Microsoft's implementation is equal to the ISO/IEC 9797-1 MAC algorithm. This will give you code samples on how to create something similar to what you need. Microsoft has implemented several cryptographic service providers for you to use. It is now up to you to read what is available on MSDN and try to use the crypto APIs to do what you need them to do or write your own custom crypto service provider.

Please be advised that it is never a good idea to create your own crypto service provider since there may be problems with the security of your algorithm. The CSPs provided by Microsoft have been throughly tested.
May 29 '07 #15
I have studied that DES CBC algorithm generate 64 bits (8 byte Hex) encrypted output but when i implement the algorithm in vb.net it gives the same length output as my plain text.i need help on how i obtain 8 byte encrypted output.

Private key() As Byte = {1, 2, 3, 4, 5, 6, 7, 8}
Private iv() As Byte = {65, 110, 68, 26, 69, 178, 200, 219}

Dim plainText As String
plainText = "HelloWorldhjslkajldalkdjlaksjdlakdja"
Dim DES As New System.Security.Cryptography.DESCryptoServiceProvi der
' Set the cipher mode.
DES.Mode = System.Security.Cryptography.CipherMode.CBC
' Create the encryptor.
Dim DESEncrypt As System.Security.Cryptography.ICryptoTransform = DES.CreateEncryptor(Me.key, Me.iv)
' Get a byte array of the string.
Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(plainText )
' Transform and return the string.
Dim keyout As String
keyout = Convert.ToBase64String(DESEncrypt.TransformFinalBl ock(Buffer, 0, Buffer.Length))
May 30 '07 #16
RedSon
5,000 Expert 4TB
I have studied that DES CBC algorithm generate 64 bits (8 byte Hex) encrypted output but when i implement the algorithm in vb.net it gives the same length output as my plain text.i need help on how i obtain 8 byte encrypted output.

Private key() As Byte = {1, 2, 3, 4, 5, 6, 7, 8}
Private iv() As Byte = {65, 110, 68, 26, 69, 178, 200, 219}

Dim plainText As String
plainText = "HelloWorldhjslkajldalkdjlaksjdlakdja"
Dim DES As New System.Security.Cryptography.DESCryptoServiceProvi der
' Set the cipher mode.
DES.Mode = System.Security.Cryptography.CipherMode.CBC
' Create the encryptor.
Dim DESEncrypt As System.Security.Cryptography.ICryptoTransform = DES.CreateEncryptor(Me.key, Me.iv)
' Get a byte array of the string.
Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(plainText )
' Transform and return the string.
Dim keyout As String
keyout = Convert.ToBase64String(DESEncrypt.TransformFinalBl ock(Buffer, 0, Buffer.Length))
I might be missing something but I do not see a call to ComputeHash().
May 30 '07 #17
ComputeHash function is available in MD5CryptoServiceProvider Class but in DESCryptoServiceProvider Class ComputeHash is not available instead it will provide ICryptoTransform function which uses CreateEncryptor method.

I studied that DES provide 8 byte output key but unable to generate the output key in 8 byte.waiting for any help?
May 31 '07 #18
pbmods
5,821 Expert 4TB
I have studied that DES CBC algorithm generate 64 bits (8 byte Hex) encrypted output but when i implement the algorithm in vb.net it gives the same length output as my plain text.i need help on how i obtain 8 byte encrypted output.

Private key() As Byte = {1, 2, 3, 4, 5, 6, 7, 8}
Private iv() As Byte = {65, 110, 68, 26, 69, 178, 200, 219}

Dim plainText As String
plainText = "HelloWorldhjslkajldalkdjlaksjdlakdja"
Dim DES As New System.Security.Cryptography.DESCryptoServiceProvi der
' Set the cipher mode.
DES.Mode = System.Security.Cryptography.CipherMode.CBC
' Create the encryptor.
Dim DESEncrypt As System.Security.Cryptography.ICryptoTransform = DES.CreateEncryptor(Me.key, Me.iv)
' Get a byte array of the string.
Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(plainText )
' Transform and return the string.
Dim keyout As String
keyout = Convert.ToBase64String(DESEncrypt.TransformFinalBl ock(Buffer, 0, Buffer.Length))
What does this output? Give us an example.
What were you expecting? Give us an example.
May 31 '07 #19
Banfa
9,065 Expert Mod 8TB
You might also consider telling us why you want to do this. You keep telling us what you want to do, the why often helps understand the problem too.
May 31 '07 #20
Basically i am developing a message interface document and send/receive data to server from my application using winsock TCP/IP. There is a MAC field in the document which apply CBC MAC encryption to plain text that i send to server and return 8 byte key in output.Then i send this 8 byte key with my plain text and the server check my message with their interface. At the server end their is a third party involved which developed server interface so they check my message and gives reply to me either transaction is OK/CANCEL.
When i am using TripleDES it generate 8 byte MAC Key but i want to generate CBC MAC key using DES.The code for TripleDES key is:
dim plaintext as string
plainText = "465465447987521234498798431321879841321465464 "
Dim data As Byte() = ASCIIEncoding.ASCII.GetBytes(plainText)
Dim mac3des As New MACTripleDES
Dim result As Byte() = mac3des.ComputeHash(data)
output=(result=52637299) 8 byte

Code for DES key is:
'Dim DES As New DESCryptoServiceProvider
'' Set the cipher mode.
'DES.Mode = CipherMode.CBC
'Dim data As Byte() = ASCIIEncoding.ASCII.GetBytes(plainText)
'If key Is Nothing Then
' DES.GenerateKey()
' DES.GenerateIV()
' key = DES.Key
' iv = DES.IV
'Else
' DES.Key = key
' DES.IV = iv
'End If

'Dim DESEncrypt As ICryptoTransform = DES.CreateEncryptor()
'Dim ms As New MemoryStream
'Dim cs As CryptoStream = New CryptoStream(ms, DESEncrypt, CryptoStreamMode.Write)
'cs.Write(data, 0, data.Length)
'cs.FlushFinalBlock()
'ms.Position = 0
'Dim result(ms.Length - 1) As Byte
'ms.Read(result, 0, ms.Length)
'cs.Close()
'Dim keyout As Byte()
'keyout = result
output=same length as plain text,i want keyout should be 8 byte.
I hope you understand this.
Jun 1 '07 #21

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: hopehope_123 | last post by:
Hi , Where can i find information about db2 block structure? I want to know how it stores rows into blocks , how it handles issues such as row migration / chaining or etc. Kind Regards,...
5
by: Michael Sperlle | last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems to need changes to the kernel before it can be installed, and I have no intention of going through whatever hell that would...
6
by: nickdu | last post by:
I usually try to stay away from _alloca(). However, I'm considering using it for a logging function. Our current logging function maintains its own buffer which it grows to fit the string being...
2
by: Julio C. Hernandez Castro | last post by:
Dear all, We have just developped a new block cipher called Raiden, following a Feistel Network structure by means of genetic programming. Our intention now consists on getting as much feedback...
2
by: Bernard Dhooghe | last post by:
The information center writes: "Encryption Algorithm: The internal encryption algorithm used is RC2 block cipher with padding, the 128-bit secret key is derived from the password using a MD2...
0
by: yaipa | last post by:
I snipped this bit of code out of Andrew Kuchling 'pyCrypto' test fixture. Having a need to XOR Binascii Hex strings in my current project, I found it very helpful to cut down on a bit of code...
2
by: danishce | last post by:
Hi, I need to calculate the Cryptographic checksum using ISO/IEC 9797-1 MAC algorithm with cipher block chaining MAC. The resultant MAC length must be 8 bytes. As a sample, the data I am...
4
by: wagn31 | last post by:
i need to use a cipher but I have to used the assigned code in the ciphering i know how to do it, but i am not sure how to add my own dictionary. Here is what i have so far:
12
by: iu2 | last post by:
Hi I'm trying to make a method call automatically to its super using this syntax: class A: chained = def pr(self): print 'Hello from A'
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.