Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP's openssl_sign generates different signature than SSCrypto's sign
    primarykey
    data
    text
    <p>I'm writing an OS X client for a software that is written in PHP. This software uses a simple RPC interface to receive and execute commands. The RPC client has to sign the commands he sends to ensure that no MITM can modify any of them.</p> <p>However, as the server was not accepting the signatures I sent from my OS X client, I started investigating and found out that PHP's openssl_sign function generates a different signature for a given private key/data combination than the Objective-C <a href="http://septicus.com/products/opensource/" rel="nofollow noreferrer">SSCrypto</a> framework (which is only a wrapper for the openssl lib):</p> <pre><code>SSCrypto *crypto = [[SSCrypto alloc] initWithPrivateKey:self.localPrivKey]; NSData *shaed = [self sha1:@"hello"]; [crypto setClearTextWithData:shaed]; NSData *data = [crypto sign]; </code></pre> <p>generates a signature like <code>CtbkSxvqNZ+mAN</code>...</p> <p>The PHP code</p> <pre><code>openssl_sign("hello", $signature, $privateKey); </code></pre> <p>generates a signature like <code>6u0d2qjFiMbZ+</code>... (For my certain key, of course. base64 encoded)</p> <p>I'm not quite shure why this is happening and I unsuccessfully experimented with different hash-algorithms. As the PHP documentation states SHA1 is used by default.</p> <p>So why do these two functions generate different signatures and how can I get my Objective-C part to generate a signature that PHPs openssl_verify will accept?</p> <p>Note: I double checked that the keys and the data is correct!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload