Re: [Twisted-Python] Regarding the SHA 512 support in twisted.

2017-03-27 Thread jabir Mohammed (jamohamm)
Hi Team,

Wanted to bring one code changes which is really required from twisted side 
otherwise it is not behaving  as per RFC (rfc4253 Section 7.2), twisted is 
failing when we negotiate any kex algorithm based on SHA1 and we have MAC as 
hmac-sha2-512. The reason for the failure was the below code

hashProcessor = _kex.getHashProcessor(self.kexAlg)
k1 = hashProcessor(sharedSecret + exchangeHash + c + self.sessionID)
k1 = k1.digest()
k2 = hashProcessor(sharedSecret + exchangeHash + k1).digest()
return k1 + k2

For SHA512 we need 64 byte key and if the Kex is based on SHA1 then it will 
only generate 40 byte key and that induce a failure. So we need to modify the 
code as below to make it generic and make it comply with RFC (rfc4253 Section 
7.2). So that twisted can work irrespective of what kex is been used. Actual 
code should plot in is like below

hashProcessor = _kex.getHashProcessor(self.kexAlg)
k1 = hashProcessor(sharedSecret + exchangeHash + c + self.sessionID)
k1 = k1.digest()
k2 = hashProcessor(sharedSecret + exchangeHash + k1).digest()
k3 = hashProcessor(sharedSecret + exchangeHash + k1 + k2).digest()
k4 = hashProcessor(sharedSecret + exchangeHash + k1 + k2 + k3).digest()
return k1 + k2 + k3 + k4

Can somebody help me to plot this fix so that twisted will work fine with all 
the other servers out there and even make it comply to the RFC. Thanks in 
advance and this will be my first findings on twisted code ;). Please let me 
know in case of any doubt on the same. Code changes should be plotted in to  
the routine _getKey,  file name is src/twisted/conch/ssh/transport.py . Please 
help me with this commit team.


Thanks,
Jabir
 \|/
---
   (  o o  )
oooO---O---Oooonull

From: Alex Gaynor mailto:alex.gay...@gmail.com>>
Date: Wednesday, 1 March 2017 9:26 am
To: jabir mohammed mailto:jamoh...@cisco.com>>
Cc: Itamar Turner-Trauring mailto:ita...@itamarst.org>>, 
"secur...@twistedmatrix.com" 
mailto:secur...@twistedmatrix.com>>
Subject: Re: Regarding the SHA 512 support in twisted.

This doesn't appear to be a security issue. You can file an issue on the public 
tracker.

Alex

On Tue, Feb 28, 2017 at 10:54 PM, jabir Mohammed (jamohamm) 
mailto:jamoh...@cisco.com>> wrote:

Thanks Alex for the response. In our server we added support of HMAC-SHA-512 
and HMAC-SHA-256 support for MAC. When we try to negotiate this hmac with most 
of the other client like Paramiko, OpenSSH and other flavours of SSH its 
working fine. But we are seeing a problem with twisted client that too only 
with HMAC-SHA-512. We have a limitation from our side to debug this since we 
don’t know what is happening from the client side. We have taken our derived 
key for the HMAC and as well as the input to derive the MAC using online tools 
and it matches with whatever we have generated but whatever is been sent across 
the other Twisted side differs and we are closing the session. This is been 
tagged critical since most of the customers are migrating to Twisted and will 
be a deployment blocker for us.

What we suspect is the key or the algorithm itself. Please see the snippet below

This is our inmac Key

RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: ssh_integrity_check: 
inmac.key
RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]:  - a5 cb a5 bb 
4c 34 a7 bf-95 e9 00 23 1e 09 17 0c   L4.#
RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: 0010 - 1c e1 3f d9 
a7 42 d9 87-54 23 64 16 e5 e2 c3 76   ..?..B..T#dv
RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: 0020 - 2a bc 53 c6 
85 78 81 eb-e4 3e fb f7 cc a3 1f 6e   *.S..x...>.n
RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: 0030 - d9 a5 0e 73 
d0 44 79 a9-d3 19 32 3b 26 92 bb 70   ...s.Dy...2;&..p

This is our input data to the hmac-sha-512
-
RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: ssh_integrity_check: 
input.data to HMAC API
RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]:  - 00 00 00 03 
00 00 00 1c-0a 05 00 00 00 0c 73 73   ..ss
RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: 0010 - 68 2d 75 73 
65 72 61 75-74 68 64 de 66 fb ab 31   h-userauthd.f..1
RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: 0020 - ba 7e 56 e5 
  .~V.

The digest which is been sent from the twisted client side(Red)
---
RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: ssh_integrity_check: digest
RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]:  - 95 f7 99 27 
48 28 35 da-62 92 0e 51 0f af 62 b1   ...'H(5.b..Q..b.
RP/0/RSP0/CPU0:Feb 23 18:12:43.896 : SSHD_[65795]: 0010 - 93 d1 4d 46 
5f d9 21 7a-b9 fb 86 b6 6e 00 a3 aa   ..MF_.!zn...
RP/0/RSP0/CPU0:Feb 23 18:12:43.896 : SSHD_[65795]: 0020 - 84 a9 58 60 
5e 1c 86 98-b4 1f 00 40 d5 72 

Re: [Twisted-Python] Regarding the SHA 512 support in twisted.

2017-03-27 Thread Adi Roiban
Hi Jarib,

Thanks for the details.

On 27 March 2017 at 10:33, jabir Mohammed (jamohamm)  wrote:
> Hi Team,
>
> Wanted to bring one code changes which is really required from twisted side
> otherwise it is not behaving  as per RFC (rfc4253 Section 7.2), twisted is
> failing when we negotiate any kex algorithm based on SHA1 and we have MAC as
> hmac-sha2-512. The reason for the failure was the below code
>
> hashProcessor = _kex.getHashProcessor(self.kexAlg)
> k1 = hashProcessor(sharedSecret + exchangeHash + c + self.sessionID)
> k1 = k1.digest()
> k2 = hashProcessor(sharedSecret + exchangeHash + k1).digest()
> return k1 + k2
>
> For SHA512 we need 64 byte key and if the Kex is based on SHA1 then it will
> only generate 40 byte key and that induce a failure. So we need to modify
> the code as below to make it generic and make it comply with RFC (rfc4253
> Section 7.2). So that twisted can work irrespective of what kex is been
> used. Actual code should plot in is like below
>
> hashProcessor = _kex.getHashProcessor(self.kexAlg)
> k1 = hashProcessor(sharedSecret + exchangeHash + c + self.sessionID)
> k1 = k1.digest()
> k2 = hashProcessor(sharedSecret + exchangeHash + k1).digest()
> k3 = hashProcessor(sharedSecret + exchangeHash + k1 + k2).digest()
> k4 = hashProcessor(sharedSecret + exchangeHash + k1 + k2 + k3).digest()
> return k1 + k2 + k3 + k4
>
> Can somebody help me to plot this fix so that twisted will work fine with
> all the other servers out there and even make it comply to the RFC. Thanks
> in advance and this will be my first findings on twisted code ;). Please let
> me know in case of any doubt on the same. Code changes should be plotted in
> to  the routine _getKey,  file name is src/twisted/conch/ssh/transport.py .
> Please help me with this commit team.

Happy to help.

Here should be the documentation for contributing  (hopefully is up to date)

http://twistedmatrix.com/trac/wiki/TwistedDevelopment

The first thing is to fork twisted/twisted, apply the change on the
branch and then create a PR.

By creating the PR, you will trigger some of the automated tests and
you can get a quick feedback.
.. for example to see if your changes are not introducing any regressions.

In an ideal world before making the changes and creating a simple
example so that we can manually check the changes you start by
updating the existing automated test to make sure that we don't
introduce regressions in the feature (as a non exhaustive list of
reasons)

You can use this file
https://github.com/twisted/twisted/blob/trunk/docs/conch/examples/sshsimpleserver.py
as the foundation for a simple example.
In the PR you can provide the client-side command use for the manual test

Looking forward for you PR.
I can help with the review and/or writing the automated tests.

You can also find me on #twisted-dev

Thanks,
Adi

> From: Alex Gaynor 
> Date: Wednesday, 1 March 2017 9:26 am
> To: jabir mohammed 
> Cc: Itamar Turner-Trauring ,
> "secur...@twistedmatrix.com" 
> Subject: Re: Regarding the SHA 512 support in twisted.
>
> This doesn't appear to be a security issue. You can file an issue on the
> public tracker.
>
> Alex
>
> On Tue, Feb 28, 2017 at 10:54 PM, jabir Mohammed (jamohamm)
>  wrote:
>>
>>
>> Thanks Alex for the response. In our server we added support of
>> HMAC-SHA-512 and HMAC-SHA-256 support for MAC. When we try to negotiate this
>> hmac with most of the other client like Paramiko, OpenSSH and other flavours
>> of SSH its working fine. But we are seeing a problem with twisted client
>> that too only with HMAC-SHA-512. We have a limitation from our side to debug
>> this since we don’t know what is happening from the client side. We have
>> taken our derived key for the HMAC and as well as the input to derive the
>> MAC using online tools and it matches with whatever we have generated but
>> whatever is been sent across the other Twisted side differs and we are
>> closing the session. This is been tagged critical since most of the
>> customers are migrating to Twisted and will be a deployment blocker for us.
>>
>> What we suspect is the key or the algorithm itself. Please see the snippet
>> below
>>
>> This is our inmac Key
>> 
>> RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: ssh_integrity_check:
>> inmac.key
>> RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]:  - a5 cb a5 bb 4c
>> 34 a7 bf-95 e9 00 23 1e 09 17 0c   L4.#
>> RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: 0010 - 1c e1 3f d9 a7
>> 42 d9 87-54 23 64 16 e5 e2 c3 76   ..?..B..T#dv
>> RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: 0020 - 2a bc 53 c6 85
>> 78 81 eb-e4 3e fb f7 cc a3 1f 6e   *.S..x...>.n
>> RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: 0030 - d9 a5 0e 73 d0
>> 44 79 a9-d3 19 32 3b 26 92 bb 70   ...s.Dy...2;&..p
>>
>> This is our input data to the hmac-sha-512
>> -
>> RP

Re: [Twisted-Python] Regarding the SHA 512 support in twisted.

2017-03-27 Thread jabir Mohammed (jamohamm)

Its a security issue even you are allowing a weaker key in case of 64 bytes 
deriving only 40 bytes. Let me know how we issue a tracker bug can you please 
guide me. Since don’t want someone else to waist effort in debugging the same 
issue.


Thanks,
Jabir
 \|/
---
   (  o o  )
oooO---O---Oooonull

From: Alex Gaynor mailto:alex.gay...@gmail.com>>
Date: Monday, 27 March 2017 4:34 pm
To: jabir mohammed mailto:jamoh...@cisco.com>>
Cc: Itamar Turner-Trauring mailto:ita...@itamarst.org>>, 
"secur...@twistedmatrix.com" 
mailto:secur...@twistedmatrix.com>>, Twisted 
general discussion 
mailto:twisted-python@twistedmatrix.com>>, 
"twisted-python-boun...@twistedmatrix.com"
 
mailto:twisted-python-boun...@twistedmatrix.com>>
Subject: Re: Regarding the SHA 512 support in twisted.

This is not a security issue, so this address isn't the right place for this 
discussion. Please use the public twisted issue tracker.

Alex

On Mon, Mar 27, 2017 at 5:33 AM, jabir Mohammed (jamohamm) 
mailto:jamoh...@cisco.com>> wrote:
Hi Team,

Wanted to bring one code changes which is really required from twisted side 
otherwise it is not behaving  as per RFC (rfc4253 Section 7.2), twisted is 
failing when we negotiate any kex algorithm based on SHA1 and we have MAC as 
hmac-sha2-512. The reason for the failure was the below code

hashProcessor = _kex.getHashProcessor(self.kexAlg)
k1 = hashProcessor(sharedSecret + exchangeHash + c + self.sessionID)
k1 = k1.digest()
k2 = hashProcessor(sharedSecret + exchangeHash + k1).digest()
return k1 + k2

For SHA512 we need 64 byte key and if the Kex is based on SHA1 then it will 
only generate 40 byte key and that induce a failure. So we need to modify the 
code as below to make it generic and make it comply with RFC (rfc4253 Section 
7.2). So that twisted can work irrespective of what kex is been used. Actual 
code should plot in is like below

hashProcessor = _kex.getHashProcessor(self.kexAlg)
k1 = hashProcessor(sharedSecret + exchangeHash + c + self.sessionID)
k1 = k1.digest()
k2 = hashProcessor(sharedSecret + exchangeHash + k1).digest()
k3 = hashProcessor(sharedSecret + exchangeHash + k1 + k2).digest()
k4 = hashProcessor(sharedSecret + exchangeHash + k1 + k2 + k3).digest()
return k1 + k2 + k3 + k4

Can somebody help me to plot this fix so that twisted will work fine with all 
the other servers out there and even make it comply to the RFC. Thanks in 
advance and this will be my first findings on twisted code ;). Please let me 
know in case of any doubt on the same. Code changes should be plotted in to  
the routine _getKey,  file name is src/twisted/conch/ssh/transport.py . Please 
help me with this commit team.


Thanks,
Jabir
 \|/
---
   (  o o  )
oooO---O---Oooonull

From: Alex Gaynor mailto:alex.gay...@gmail.com>>
Date: Wednesday, 1 March 2017 9:26 am
To: jabir mohammed mailto:jamoh...@cisco.com>>
Cc: Itamar Turner-Trauring mailto:ita...@itamarst.org>>, 
"secur...@twistedmatrix.com" 
mailto:secur...@twistedmatrix.com>>
Subject: Re: Regarding the SHA 512 support in twisted.

This doesn't appear to be a security issue. You can file an issue on the public 
tracker.

Alex

On Tue, Feb 28, 2017 at 10:54 PM, jabir Mohammed (jamohamm) 
mailto:jamoh...@cisco.com>> wrote:

Thanks Alex for the response. In our server we added support of HMAC-SHA-512 
and HMAC-SHA-256 support for MAC. When we try to negotiate this hmac with most 
of the other client like Paramiko, OpenSSH and other flavours of SSH its 
working fine. But we are seeing a problem with twisted client that too only 
with HMAC-SHA-512. We have a limitation from our side to debug this since we 
don’t know what is happening from the client side. We have taken our derived 
key for the HMAC and as well as the input to derive the MAC using online tools 
and it matches with whatever we have generated but whatever is been sent across 
the other Twisted side differs and we are closing the session. This is been 
tagged critical since most of the customers are migrating to Twisted and will 
be a deployment blocker for us.

What we suspect is the key or the algorithm itself. Please see the snippet below

This is our inmac Key

RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: ssh_integrity_check: 
inmac.key
RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]:  - a5 cb a5 bb 
4c 34 a7 bf-95 e9 00 23 1e 09 17 0c   L4.#
RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: 0010 - 1c e1 3f d9 
a7 42 d9 87-54 23 64 16 e5 e2 c3 76   ..?..B..T#dv
RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: 0020 - 2a bc 53 c6 
85 78 81 eb-e4 3e fb f7 cc a3 1f 6e   *.S..x...>.n
RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: 0030 - d9 a5 0e 73 
d0 44 79 a9-d3 19 32 3b 26 92 bb 70   ...s.Dy...2;&..p

This is our 

Re: [Twisted-Python] Regarding the SHA 512 support in twisted.

2017-03-27 Thread jabir Mohammed (jamohamm)
No probs Adi, can you help me to upload the fix to the twisted since I
don¹t know the procedure, if you can guide me that helps. Since I was
pretty sure that this a bug in coding twisted set keys part and not comply
to RFC.


Thanks,
Jabir
 \|/
---
   (  o o  )
oooO---O---Oooonull




On 27/03/17 4:06 pm, "Twisted-Python on behalf of Adi Roiban"

wrote:

>Hi Jarib,
>
>Thanks for the details.
>
>On 27 March 2017 at 10:33, jabir Mohammed (jamohamm) 
>wrote:
>> Hi Team,
>>
>> Wanted to bring one code changes which is really required from twisted
>>side
>> otherwise it is not behaving  as per RFC (rfc4253 Section 7.2), twisted
>>is
>> failing when we negotiate any kex algorithm based on SHA1 and we have
>>MAC as
>> hmac-sha2-512. The reason for the failure was the below code
>>
>> hashProcessor = _kex.getHashProcessor(self.kexAlg)
>> k1 = hashProcessor(sharedSecret + exchangeHash + c +
>>self.sessionID)
>> k1 = k1.digest()
>> k2 = hashProcessor(sharedSecret + exchangeHash + k1).digest()
>> return k1 + k2
>>
>> For SHA512 we need 64 byte key and if the Kex is based on SHA1 then it
>>will
>> only generate 40 byte key and that induce a failure. So we need to
>>modify
>> the code as below to make it generic and make it comply with RFC
>>(rfc4253
>> Section 7.2). So that twisted can work irrespective of what kex is been
>> used. Actual code should plot in is like below
>>
>> hashProcessor = _kex.getHashProcessor(self.kexAlg)
>> k1 = hashProcessor(sharedSecret + exchangeHash + c +
>>self.sessionID)
>> k1 = k1.digest()
>> k2 = hashProcessor(sharedSecret + exchangeHash + k1).digest()
>> k3 = hashProcessor(sharedSecret + exchangeHash + k1 + k2).digest()
>> k4 = hashProcessor(sharedSecret + exchangeHash + k1 + k2 + k3).digest()
>> return k1 + k2 + k3 + k4
>>
>> Can somebody help me to plot this fix so that twisted will work fine
>>with
>> all the other servers out there and even make it comply to the RFC.
>>Thanks
>> in advance and this will be my first findings on twisted code ;).
>>Please let
>> me know in case of any doubt on the same. Code changes should be
>>plotted in
>> to  the routine _getKey,  file name is
>>src/twisted/conch/ssh/transport.py .
>> Please help me with this commit team.
>
>Happy to help.
>
>Here should be the documentation for contributing  (hopefully is up to
>date)
>
>http://twistedmatrix.com/trac/wiki/TwistedDevelopment
>
>The first thing is to fork twisted/twisted, apply the change on the
>branch and then create a PR.
>
>By creating the PR, you will trigger some of the automated tests and
>you can get a quick feedback.
>.. for example to see if your changes are not introducing any regressions.
>
>In an ideal world before making the changes and creating a simple
>example so that we can manually check the changes you start by
>updating the existing automated test to make sure that we don't
>introduce regressions in the feature (as a non exhaustive list of
>reasons)
>
>You can use this file
>https://github.com/twisted/twisted/blob/trunk/docs/conch/examples/sshsimpl
>eserver.py
>as the foundation for a simple example.
>In the PR you can provide the client-side command use for the manual test
>
>Looking forward for you PR.
>I can help with the review and/or writing the automated tests.
>
>You can also find me on #twisted-dev
>
>Thanks,
>Adi
>
>> From: Alex Gaynor 
>> Date: Wednesday, 1 March 2017 9:26 am
>> To: jabir mohammed 
>> Cc: Itamar Turner-Trauring ,
>> "secur...@twistedmatrix.com" 
>> Subject: Re: Regarding the SHA 512 support in twisted.
>>
>> This doesn't appear to be a security issue. You can file an issue on the
>> public tracker.
>>
>> Alex
>>
>> On Tue, Feb 28, 2017 at 10:54 PM, jabir Mohammed (jamohamm)
>>  wrote:
>>>
>>>
>>> Thanks Alex for the response. In our server we added support of
>>> HMAC-SHA-512 and HMAC-SHA-256 support for MAC. When we try to
>>>negotiate this
>>> hmac with most of the other client like Paramiko, OpenSSH and other
>>>flavours
>>> of SSH its working fine. But we are seeing a problem with twisted
>>>client
>>> that too only with HMAC-SHA-512. We have a limitation from our side to
>>>debug
>>> this since we don¹t know what is happening from the client side. We
>>>have
>>> taken our derived key for the HMAC and as well as the input to derive
>>>the
>>> MAC using online tools and it matches with whatever we have generated
>>>but
>>> whatever is been sent across the other Twisted side differs and we are
>>> closing the session. This is been tagged critical since most of the
>>> customers are migrating to Twisted and will be a deployment blocker
>>>for us.
>>>
>>> What we suspect is the key or the algorithm itself. Please see the
>>>snippet
>>> below
>>>
>>> This is our inmac Key
>>> 
>>> RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: ssh_integrity_check:
>>> inmac.key
>>> RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]:  - a5 cb a5 bb
>>>4c
>>> 34 a7 bf-95 e9 00 2

Re: [Twisted-Python] Regarding the SHA 512 support in twisted.

2017-03-27 Thread Adi Roiban
On 27 March 2017 at 12:07, jabir Mohammed (jamohamm)  wrote:
>
> Its a security issue even you are allowing a weaker key in case of 64 bytes
> deriving only 40 bytes. Let me know how we issue a tracker bug can you
> please guide me. Since don’t want someone else to waist effort in debugging
> the same issue.

Hi Jabir and sorry for the previous misspelling!

There are a few existing bug reports for KEX related tasks...some are
server side, some are client side

https://twistedmatrix.com/trac/search?q=kex

I think that your bug was already reported (by my) at
https://twistedmatrix.com/trac/ticket/8258

-

Regarding the help with this patch.

What have you tried so far?
Where are you stuck?
Where/ with what specifically do you need help?



Thanks!

>
> Thanks,
>
> Jabir
>
>  \|/
>
> ---
>
>(  o o  )
>
> oooO---O---Oooonull
>
>
> From: Alex Gaynor 
> Date: Monday, 27 March 2017 4:34 pm
> To: jabir mohammed 
> Cc: Itamar Turner-Trauring ,
> "secur...@twistedmatrix.com" , Twisted general
> discussion ,
> "twisted-python-boun...@twistedmatrix.com"
> 
> Subject: Re: Regarding the SHA 512 support in twisted.
>
> This is not a security issue, so this address isn't the right place for this
> discussion. Please use the public twisted issue tracker.
>
> Alex
>
> On Mon, Mar 27, 2017 at 5:33 AM, jabir Mohammed (jamohamm)
>  wrote:
>>
>> Hi Team,
>>
>> Wanted to bring one code changes which is really required from twisted
>> side otherwise it is not behaving  as per RFC (rfc4253 Section 7.2), twisted
>> is failing when we negotiate any kex algorithm based on SHA1 and we have MAC
>> as hmac-sha2-512. The reason for the failure was the below code
>>
>> hashProcessor = _kex.getHashProcessor(self.kexAlg)
>> k1 = hashProcessor(sharedSecret + exchangeHash + c +
>> self.sessionID)
>> k1 = k1.digest()
>> k2 = hashProcessor(sharedSecret + exchangeHash + k1).digest()
>> return k1 + k2
>>
>> For SHA512 we need 64 byte key and if the Kex is based on SHA1 then it
>> will only generate 40 byte key and that induce a failure. So we need to
>> modify the code as below to make it generic and make it comply with RFC
>> (rfc4253 Section 7.2). So that twisted can work irrespective of what kex is
>> been used. Actual code should plot in is like below
>>
>> hashProcessor = _kex.getHashProcessor(self.kexAlg)
>> k1 = hashProcessor(sharedSecret + exchangeHash + c +
>> self.sessionID)
>> k1 = k1.digest()
>> k2 = hashProcessor(sharedSecret + exchangeHash + k1).digest()
>> k3 = hashProcessor(sharedSecret + exchangeHash + k1 + k2).digest()
>> k4 = hashProcessor(sharedSecret + exchangeHash + k1 + k2 + k3).digest()
>> return k1 + k2 + k3 + k4
>>
>> Can somebody help me to plot this fix so that twisted will work fine with
>> all the other servers out there and even make it comply to the RFC. Thanks
>> in advance and this will be my first findings on twisted code ;). Please let
>> me know in case of any doubt on the same. Code changes should be plotted in
>> to  the routine _getKey,  file name is src/twisted/conch/ssh/transport.py .
>> Please help me with this commit team.
>>
>>
>> Thanks,
>>
>> Jabir
>>
>>  \|/
>>
>> ---
>>
>>(  o o  )
>>
>> oooO---O---Oooonull
>>
>>
>> From: Alex Gaynor 
>> Date: Wednesday, 1 March 2017 9:26 am
>> To: jabir mohammed 
>> Cc: Itamar Turner-Trauring ,
>> "secur...@twistedmatrix.com" 
>> Subject: Re: Regarding the SHA 512 support in twisted.
>>
>> This doesn't appear to be a security issue. You can file an issue on the
>> public tracker.
>>
>> Alex
>>
>> On Tue, Feb 28, 2017 at 10:54 PM, jabir Mohammed (jamohamm)
>>  wrote:
>>>
>>>
>>> Thanks Alex for the response. In our server we added support of
>>> HMAC-SHA-512 and HMAC-SHA-256 support for MAC. When we try to negotiate this
>>> hmac with most of the other client like Paramiko, OpenSSH and other flavours
>>> of SSH its working fine. But we are seeing a problem with twisted client
>>> that too only with HMAC-SHA-512. We have a limitation from our side to debug
>>> this since we don’t know what is happening from the client side. We have
>>> taken our derived key for the HMAC and as well as the input to derive the
>>> MAC using online tools and it matches with whatever we have generated but
>>> whatever is been sent across the other Twisted side differs and we are
>>> closing the session. This is been tagged critical since most of the
>>> customers are migrating to Twisted and will be a deployment blocker for us.
>>>
>>> What we suspect is the key or the algorithm itself. Please see the
>>> snippet below
>>>
>>> This is our inmac Key
>>> 
>>> RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: ssh_integrity_check:
>>> inmac.key
>>> RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]:  - a5 cb a5 bb 4c
>>> 34 a7 bf-95 e9 00 23 1e 09 17 0c   L4.#
>>> RP/0/RSP0/CPU0:Feb 23 18:12:43.895 : SSHD_[65795]: 0010 - 1c e1 3f d9 a7
>>> 42 d9 87-54 23 64 16

Re: [Twisted-Python] Regarding the SHA 512 support in twisted.

2017-03-27 Thread jabir Mohammed (jamohamm)
Please see inline comments [[>> Jamohamm: <<]]. Thanks for the response
team.

Thanks,
Jabir
 \|/
---
   (  o o  )
oooO---O---Oooonull




On 27/03/17 6:45 pm, "Twisted-Python on behalf of Adi Roiban"

wrote:

>On 27 March 2017 at 12:07, jabir Mohammed (jamohamm) 
>wrote:
>>
>> Its a security issue even you are allowing a weaker key in case of 64
>>bytes
>> deriving only 40 bytes. Let me know how we issue a tracker bug can you
>> please guide me. Since don¹t want someone else to waist effort in
>>debugging
>> the same issue.
>
>Hi Jabir and sorry for the previous misspelling!
>
>There are a few existing bug reports for KEX related tasks...some are
>server side, some are client side
>
>https://twistedmatrix.com/trac/search?q=kex
>
>I think that your bug was already reported (by my) at
>https://twistedmatrix.com/trac/ticket/8258

[[>> Jamohamm: So this is the bug which is tracking the issue, sounds good
but its 12 months old but still nobody fixed this interesting. <<]]

>
>-
>
>Regarding the help with this patch.
>
>What have you tried so far?

[[>> Jamohamm: We recompiled the twisted SSH client code with the fix and
it working fine with OpenSSH server and our server as well, so wanted to
plot the fix in next maintenance release of twisted. <<]]

>Where are you stuck?

[[>> Jamohamm: Since I didn¹t get any response from the community we
debugged and figured out the issue with coding in twisted SSH client code.
So as of now I am not stuck and we are good with twisted SSH client and
its working fine with this fix. <<]]

>Where/ with what specifically do you need help?

[[>> Jamohamm: Can we upload the fix and get it committed to twisted,
someone can help me with that. <<]]
>
>
>
>Thanks!
>
>>
>> Thanks,
>>
>> Jabir
>>
>>  \|/
>>
>> ---
>>
>>(  o o  )
>>
>> oooO---O---Oooonull
>>
>>
>> From: Alex Gaynor 
>> Date: Monday, 27 March 2017 4:34 pm
>> To: jabir mohammed 
>> Cc: Itamar Turner-Trauring ,
>> "secur...@twistedmatrix.com" , Twisted
>>general
>> discussion ,
>> "twisted-python-boun...@twistedmatrix.com"
>> 
>> Subject: Re: Regarding the SHA 512 support in twisted.
>>
>> This is not a security issue, so this address isn't the right place for
>>this
>> discussion. Please use the public twisted issue tracker.
>>
>> Alex
>>
>> On Mon, Mar 27, 2017 at 5:33 AM, jabir Mohammed (jamohamm)
>>  wrote:
>>>
>>> Hi Team,
>>>
>>> Wanted to bring one code changes which is really required from twisted
>>> side otherwise it is not behaving  as per RFC (rfc4253 Section 7.2),
>>>twisted
>>> is failing when we negotiate any kex algorithm based on SHA1 and we
>>>have MAC
>>> as hmac-sha2-512. The reason for the failure was the below code
>>>
>>> hashProcessor = _kex.getHashProcessor(self.kexAlg)
>>> k1 = hashProcessor(sharedSecret + exchangeHash + c +
>>> self.sessionID)
>>> k1 = k1.digest()
>>> k2 = hashProcessor(sharedSecret + exchangeHash + k1).digest()
>>> return k1 + k2
>>>
>>> For SHA512 we need 64 byte key and if the Kex is based on SHA1 then it
>>> will only generate 40 byte key and that induce a failure. So we need to
>>> modify the code as below to make it generic and make it comply with RFC
>>> (rfc4253 Section 7.2). So that twisted can work irrespective of what
>>>kex is
>>> been used. Actual code should plot in is like below
>>>
>>> hashProcessor = _kex.getHashProcessor(self.kexAlg)
>>> k1 = hashProcessor(sharedSecret + exchangeHash + c +
>>> self.sessionID)
>>> k1 = k1.digest()
>>> k2 = hashProcessor(sharedSecret + exchangeHash + k1).digest()
>>> k3 = hashProcessor(sharedSecret + exchangeHash + k1 + k2).digest()
>>> k4 = hashProcessor(sharedSecret + exchangeHash + k1 + k2 + k3).digest()
>>> return k1 + k2 + k3 + k4
>>>
>>> Can somebody help me to plot this fix so that twisted will work fine
>>>with
>>> all the other servers out there and even make it comply to the RFC.
>>>Thanks
>>> in advance and this will be my first findings on twisted code ;).
>>>Please let
>>> me know in case of any doubt on the same. Code changes should be
>>>plotted in
>>> to  the routine _getKey,  file name is
>>>src/twisted/conch/ssh/transport.py .
>>> Please help me with this commit team.
>>>
>>>
>>> Thanks,
>>>
>>> Jabir
>>>
>>>  \|/
>>>
>>> ---
>>>
>>>(  o o  )
>>>
>>> oooO---O---Oooonull
>>>
>>>
>>> From: Alex Gaynor 
>>> Date: Wednesday, 1 March 2017 9:26 am
>>> To: jabir mohammed 
>>> Cc: Itamar Turner-Trauring ,
>>> "secur...@twistedmatrix.com" 
>>> Subject: Re: Regarding the SHA 512 support in twisted.
>>>
>>> This doesn't appear to be a security issue. You can file an issue on
>>>the
>>> public tracker.
>>>
>>> Alex
>>>
>>> On Tue, Feb 28, 2017 at 10:54 PM, jabir Mohammed (jamohamm)
>>>  wrote:


 Thanks Alex for the response. In our server we added support of
 HMAC-SHA-512 and HMAC-SHA-256 support for MAC. When we try to
negotiate this
 hmac with most of the other client like Paramiko, OpenSSH and other
>

Re: [Twisted-Python] Regarding the SHA 512 support in twisted.

2017-03-27 Thread Craig Rodrigues
On Mon, Mar 27, 2017 at 2:33 AM, jabir Mohammed (jamohamm) <
jamoh...@cisco.com> wrote:

>
> Can somebody help me to plot this fix so that twisted will work fine with
> all the other servers out there and even make it comply to the RFC. Thanks
> in advance and this will be my first findings on twisted code ;). Please
> let me know in case of any doubt on the same. Code changes should be
> plotted in to  the routine _getKey,  file name is 
> src/twisted/conch/ssh/transport.py
> . Please help me with this commit team.
>
>
You need to follow the procedure at:

https://twistedmatrix.com/trac/wiki/TwistedDevelopment#SubmittingaPatch

That will give you all the details you need about filing a new ticket in
Trac,
forking the repository on GitHub, doing a GitHub pull request, etc.

If you need more help, you should ask Einar Floystad Dorum, who works at
Cisco and has filed multiple Conch patches
for Twisted:
https://github.com/twisted/twisted/pulls?q=is%3Apr+author%3Aeinarfd+is%3Aclosed

--
Craig
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Regarding the SHA 512 support in twisted.

2017-03-27 Thread jabir Mohammed (jamohamm)

Thanks Craig shall follow up.

Thanks,
Jabir
 \|/
---
   (  o o  )
oooO---O---Oooonull

From: mailto:crodr...@gmail.com>> on behalf of Craig 
Rodrigues mailto:rodr...@crodrigues.org>>
Date: Monday, 27 March 2017 9:38 pm
To: Twisted general discussion 
mailto:twisted-python@twistedmatrix.com>>
Cc: "secur...@twistedmatrix.com" 
mailto:secur...@twistedmatrix.com>>, 
"twisted-python-boun...@twistedmatrix.com"
 
mailto:twisted-python-boun...@twistedmatrix.com>>,
 jabir mohammed mailto:jamoh...@cisco.com>>
Subject: Re: [Twisted-Python] Regarding the SHA 512 support in twisted.


On Mon, Mar 27, 2017 at 2:33 AM, jabir Mohammed (jamohamm) 
mailto:jamoh...@cisco.com>> wrote:

Can somebody help me to plot this fix so that twisted will work fine with all 
the other servers out there and even make it comply to the RFC. Thanks in 
advance and this will be my first findings on twisted code ;). Please let me 
know in case of any doubt on the same. Code changes should be plotted in to  
the routine _getKey,  file name is src/twisted/conch/ssh/transport.py . Please 
help me with this commit team.


You need to follow the procedure at:

https://twistedmatrix.com/trac/wiki/TwistedDevelopment#SubmittingaPatch

That will give you all the details you need about filing a new ticket in Trac,
forking the repository on GitHub, doing a GitHub pull request, etc.

If you need more help, you should ask Einar Floystad Dorum, who works at Cisco 
and has filed multiple Conch patches
for Twisted: 
https://github.com/twisted/twisted/pulls?q=is%3Apr+author%3Aeinarfd+is%3Aclosed

--
Craig
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python