title: Couldn't generate correct PASSWORD_CLAIM_SIGNATURE in PHP for Cognito
body: <p>I am trying to use AuthFlow <code>USER_SRP_AUTH</code> for user login. I am getting the "PASSWORD_VERIFIER" challenge in the response of initiateAuth request. While responding to that challenge I am not sure what I should pass as the value of <code>PASSWORD_CLAIM_SIGNATURE</code>. I have tried different values as per documentation and java code but no success.</p>
  
  <p>I'm using the code below for the <code>respondToAuthChallenge</code> method:</p>
  
  <pre><code>$date = date('D M d H:i:s T Y');
  
  $srp = new Srp();
  $a = $srp-&gt;getRandomSeed();
  $A = $srp-&gt;generateA($a);
  
  $challengeParameters = $result-&gt;get('ChallengeParameters');
  
  $s = $srp-&gt;getRandomSeed();
  $x = $srp-&gt;generateX($s, 'MY_USERNAME', 'MY_PASSWORD');
  $S = $srp-&gt;generateS_Client($A, $challengeParameters['SRP_B'], $a, $x);
  $K = $srp-&gt;generateK($S);
  
  $response = $client-&gt;respondToAuthChallenge([
      'ChallengeName'      =&gt; 'PASSWORD_VERIFIER',
      'ClientId'           =&gt; 'CLIENT_ID',
      'ChallengeResponses' =&gt; [
          'TIMESTAMP'                   =&gt; $date,
          'USERNAME'                    =&gt; $challengeParameters['USER_ID_FOR_SRP'],
          'PASSWORD_CLAIM_SECRET_BLOCK' =&gt; $challengeParameters['SECRET_BLOCK'],
          'PASSWORD_CLAIM_SIGNATURE'    =&gt; hash_hmac('sha256', $K, $challengeParameters['SALT'])
      ]
  ]);
  </code></pre>
  
  <p>I have used this PHP SRP Client: <a href="https://github.com/falkmueller/srp/" rel="nofollow noreferrer">https://github.com/falkmueller/srp/</a></p>
  
  <p>In the response of <code>respondToAuthChallenge</code> request, I am getting this error</p>
  
  <pre><code>400 Bad Request` response:
  {"__type":"NotAuthorizedException","message":"Incorrect username or password."}
  </code></pre>
  
  <p>Most likely this error caused by an incorrect <code>PASSWORD_CLAIM_SIGNATURE</code>. Since I haven't really found what this key should contain as a value and just tried some things based on documentation and java code I've found.</p>