Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto/des: show example of 16-byte key #3537

Closed
gopherbot opened this issue Apr 16, 2012 · 13 comments
Closed

crypto/des: show example of 16-byte key #3537

gopherbot opened this issue Apr 16, 2012 · 13 comments
Labels
FrozenDueToAge Suggested Issues that may be good for new contributors looking for work to do.
Milestone

Comments

@gopherbot
Copy link

by visan.ovidiu:

Which operating system are you using?
Ubuntu 11.10

Which version are you using?  (run 'go version')
go version go1

Please provide any additional information below.

NewTripleDESCipher should accept as minimum a 16 byte length key and as maximum the
current 24 byte lenght key.
Also it should take the initialization vector (IV) as parameter.

eg. http://msdn.microsoft.com/en-us/library/system.security.cryptography.tripledes.aspx
@rsc
Copy link
Contributor

rsc commented Apr 17, 2012

Comment 1:

This amounts to not supporting DES-EDE2, only DES-EDE3
+agl for an opinion on whether we want to do that.
It is unclear to me - it appears that Java does not support it either,
and it is trivial for clients who want to use less key to expand it
before using our 3DES.

Labels changed: added priority-later, removed priority-triage.

Status changed to Thinking.

@agl
Copy link
Contributor

agl commented Apr 17, 2012

Comment 2:

An IV can only apply to a cipher mode, not a cipher. So that's moot here.
A patch to expand a 128-bit key internally would be pretty simple. But I think I'd still
want to see some evidence that something in the real world is actually using EDE2.

@gopherbot
Copy link
Author

Comment 3 by visan.ovidiu:

As an example, sometimes i have to take some code written in C# and have the pleasure to
write it in Go. The problem here is that the C# code it's using a 16 byte key and the
encrypted text it's in a file, and i wanted to decrypt that using Go.
 
Thanks for the short reply (considering the amount of work you have).

@gopherbot
Copy link
Author

Comment 4 by visan.ovidiu:

Thanks for the short reply (considering the amount of work you have). 
As an example, sometimes i have to take some code written in C# and have the pleasure to
write it in Go. The problem here is that the C# code it's using a 16 byte key to decrypt
an existing text that's in a file, and i wanted to decrypt that text using Go.

@rsc
Copy link
Contributor

rsc commented Apr 18, 2012

Comment 5:

Just in case it's not clear, the workaround here is to use
func key16to24(key []byte) []byte {
    var b []byte
    b = append(b, key[:16]...)
    b = append(b, key[:8]...)
    return b
}
to convert your 16-byte key into the equivalent 24-byte key.
Russ

@agl
Copy link
Contributor

agl commented Apr 18, 2012

Comment 6:

As rsc points out, the workaround is easy. If lots of people will be using it then it's
worth putting in the standard library. However, DES-EDE2 is very obscure and it might
well be that you're the only person who needs it. In that case, it's obviously better if
you carry the code yourself.

@gopherbot
Copy link
Author

Comment 7 by visan.ovidiu:

Thank you very much Russ!
It worked flawlessly, thanks taking time for this.
More small examples like this would help lots of newcomers to Go.
Thanks again!

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 8:

Let's put this into a godoc example somewhere and call it done.

Status changed to Accepted.

@gopherbot
Copy link
Author

Comment 9 by visan.ovidiu:

thanks, it might help others too

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 10:

Labels changed: added go1.1.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 11:

Labels changed: added size-s.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 12:

Labels changed: added suggested.

@agl
Copy link
Contributor

agl commented Dec 22, 2012

Comment 13:

This issue was closed by revision 8f1d170.

Status changed to Fixed.

@gopherbot gopherbot added fixed Suggested Issues that may be good for new contributors looking for work to do. labels Dec 22, 2012
@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Suggested Issues that may be good for new contributors looking for work to do.
Projects
None yet
Development

No branches or pull requests

3 participants