| 1 | # NTLM Implementation for Go |
| 2 | |
| 3 | This is a native implementation of NTLM for Go that was implemented using the Microsoft MS-NLMP documentation available at http://msdn.microsoft.com/en-us/library/cc236621.aspx. |
| 4 | The library is currently in use and has been tested with connectionless NTLMv1 and v2 with and without extended session security. |
| 5 | |
| 6 | ## Usage Notes |
| 7 | |
| 8 | Currently the implementation only supports connectionless (datagram) oriented NTLM. We did not need connection oriented NTLM for our usage |
| 9 | and so it is not implemented. However it should be extremely straightforward to implement connection oriented NTLM as all |
| 10 | the operations required are present in the library. The major missing piece is the negotiation of capabilities between |
| 11 | the client and the server, for our use we hardcoded a supported set of negotiation flags. |
| 12 | |
| 13 | ## Sample Usage as NTLM Client |
| 14 | |
| 15 | ```go |
| 16 | import "github.com/ThomsonReutersEikon/go-ntlm/ntlm" |
| 17 | |
| 18 | session, err = ntlm.CreateClientSession(ntlm.Version2, ntlm.ConnectionlessMode) |
| 19 | session.SetUserInfo("someuser","somepassword","somedomain") |
| 20 | |
| 21 | negotiate := session.GenerateNegotiateMessage() |
| 22 | |
| 23 | <send negotiate to server> |
| 24 | |
| 25 | challenge, err := ntlm.ParseChallengeMessage(challengeBytes) |
| 26 | session.ProcessChallengeMessage(challenge) |
| 27 | |
| 28 | authenticate := session.GenerateAuthenticateMessage() |
| 29 | |
| 30 | <send authenticate message to server> |
| 31 | ``` |
| 32 | |
| 33 | ## Sample Usage as NTLM Server |
| 34 | |
| 35 | ```go |
| 36 | session, err := ntlm.CreateServerSession(ntlm.Version1, ntlm.ConnectionlessMode) |
| 37 | session.SetUserInfo("someuser","somepassword","somedomain") |
| 38 | |
| 39 | challenge := session.GenerateChallengeMessage() |
| 40 | |
| 41 | <send challenge to client> |
| 42 | |
| 43 | <receive authentication bytes> |
| 44 | |
| 45 | auth, err := ntlm.ParseAuthenticateMessage(authenticateBytes) |
| 46 | session.ProcessAuthenticateMessage(auth) |
| 47 | ``` |
| 48 | |
| 49 | ## Generating a message MAC |
| 50 | |
| 51 | Once a session is created you can generate the Mac for a message using: |
| 52 | |
| 53 | ```go |
| 54 | message := "this is some message to sign" |
| 55 | sequenceNumber := 100 |
| 56 | signature, err := session.Mac([]byte(message), sequenceNumber) |
| 57 | ``` |
| 58 | |
| 59 | ## License |
| 60 | Copyright Thomson Reuters Global Resources 2013 |
| 61 | Apache License |