Crypto block padding

251 views
Skip to first unread message

cam...@camlittle.com

unread,
Mar 15, 2014, 8:17:40 PM3/15/14
to golan...@googlegroups.com
Are there any plans or existing work on implementing block padding for the golang crypto package? It seems like it'd be a useful feature to have. 

agl

unread,
Mar 16, 2014, 9:23:30 AM3/16/14
to golan...@googlegroups.com, cam...@camlittle.com
On Saturday, March 15, 2014 8:17:40 PM UTC-4, cam...@camlittle.com wrote:
Are there any plans or existing work on implementing block padding for the golang crypto package? It seems like it'd be a useful feature to have. 

You mean PKCS#5 padding for CBC mode?

I'd have no objection to a patch if well done, but I would hope that people are moving away from such schemes.


Cheers

AGL 

cam...@camlittle.com

unread,
Mar 16, 2014, 12:26:11 PM3/16/14
to golan...@googlegroups.com, cam...@camlittle.com
Preferably that along with PKCS7, ANSI X.923, and whatever other common ones are out there.

What do you mean by "moving away from such schemes"? What sort of alternatives are out there for block padding? I don't know enough about cryptography to know what else is more effective.

I've got a project I'm working on that may require this, so if I come up with anything good, I'll be sure to share.

Cameron

agl

unread,
Mar 17, 2014, 3:52:51 AM3/17/14
to golan...@googlegroups.com, cam...@camlittle.com
On Sunday, March 16, 2014 12:26:11 PM UTC-4, Cameron Little wrote:
What do you mean by "moving away from such schemes"? What sort of alternatives are out there for block padding? I don't know enough about cryptography to know what else is more effective.

 When dealing with old code it can be needed, but anything new should use GCM or go.crypto/nacl/secretbox.


Cheers

AGL

Cameron Little

unread,
Mar 17, 2014, 10:02:42 PM3/17/14
to golan...@googlegroups.com, cam...@camlittle.com
Makes sense. At this point, I need it for a project, so I've gotten a start on a package. It's at https://github.com/apexskier/cryptoPadding if anyone'd like to take a look.

Cameron

Cameron Little

unread,
Mar 17, 2014, 10:10:26 PM3/17/14
to golan...@googlegroups.com, cam...@camlittle.com
I've modeled my algorithms as best I could off of the descriptions I found online.

For usage, you define a variable of the padding type, but don't initialize it. Then you can call functions it implements. I'm not sure how standard this is compared go's other stuff, but it seems clean to me.

Example:

var (
    p cryptoPadding.PKCS7
    blocksize 16
)
padded, err := p.Pad(data, blocksize)
data2, err := p.Unpad(padded, blocksize)
Reply all
Reply to author
Forward
0 new messages