<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to use cryptocell so sign data without a hash</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55458/how-to-use-cryptocell-so-sign-data-without-a-hash</link><description>In order to implement the standard RSA-PKCS, raw data must be signed with the private key without performing a hash. 
 All the CRYS functions wants either a HASH as input or want to comute a HASH inthe sign function. 
 
 How can I sign (actually encrypt</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 14 Jan 2020 09:43:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55458/how-to-use-cryptocell-so-sign-data-without-a-hash" /><item><title>RE: How to use cryptocell so sign data without a hash</title><link>https://devzone.nordicsemi.com/thread/228975?ContentTypeID=1</link><pubDate>Tue, 14 Jan 2020 09:43:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43bbd004-784f-4643-a760-c695d399261d</guid><dc:creator>Roelof</dc:creator><description>&lt;p&gt;This is a mechanism from PKCS#11 CKM_RSA_PKCS. Currently it is an OpenSSL command that I am sending to the device.&lt;/p&gt;
&lt;p&gt;&amp;quot;The PKCS #1 v1.5 RSA mechanism, denoted CKM_RSA_PKCS, is a multi-purpose mechanism based on the RSA public-key cryptosystem and the block formats initially defined in PKCS #1 v1.5. It supports single-part encryption and decryption; single-part signatures and verification with and without message recovery; key wrapping; and key unwrapping. This mechanism corresponds only to the part of PKCS #1 v1.5 that involves RSA; it does not compute a message digest or a DigestInfo encoding as specified for the md2withRSAEncryption and md5withRSAEncryption algorithms in PKCS #1 v1.5 .&lt;/p&gt;
&lt;p&gt;This mechanism does not have a parameter.&lt;/p&gt;
&lt;p&gt;This mechanism can wrap and unwrap any secret key of appropriate length. Of course, a particular token may not be able to wrap/unwrap every appropriate-length secret key that it supports. For wrapping, the &amp;ldquo;input&amp;rdquo; to the encryption operation is the value of the CKA_VALUE attribute of the key that is wrapped; similarly for unwrapping. The mechanism does not wrap the key type or any other information about the key, except the key length; the application must convey these separately. In particular, the mechanism contributes only the CKA_CLASS and CKA_VALUE (and CKA_VALUE_LEN, if the key has it) attributes to the recovered key during unwrapping; other attributes must be specified in the template.&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use cryptocell so sign data without a hash</title><link>https://devzone.nordicsemi.com/thread/228827?ContentTypeID=1</link><pubDate>Mon, 13 Jan 2020 14:13:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0cae7292-60ec-4f84-837a-2f9a72f9ec8c</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The API does not allow not hashing. However, you can try using&amp;nbsp;CRYS_RSA_HASH_NO_HASH_mode or CRYS_RSA_After_HASH_NOT_KNOWN_mode. That is just intended for testing, though. See supported modes here (excluding MD5):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*! Defines the enum for the HASH operation mode. */
typedef enum
{
	CRYS_RSA_HASH_MD5_mode  = 0,	/*!&amp;lt; For PKCS1 v1.5 only. The input data will be hashed with MD5 */
	CRYS_RSA_HASH_SHA1_mode = 1,	/*!&amp;lt; The input data will be hashed with SHA1. */
	CRYS_RSA_HASH_SHA224_mode = 2,  /*!&amp;lt; The input data will be hashed with SHA224. */
	CRYS_RSA_HASH_SHA256_mode = 3,  /*!&amp;lt; The input data will be hashed with SHA256. */
	CRYS_RSA_HASH_SHA384_mode = 4,  /*!&amp;lt; The input data will be hashed with SHA384. */
	CRYS_RSA_HASH_SHA512_mode = 5,	/*!&amp;lt; The input data will be hashed with SHA512. */
	CRYS_RSA_After_MD5_mode = 6,		/*!&amp;lt; For PKCS1 v1.5 only. The input data is a digest of MD5 and will not be hashed. */
	CRYS_RSA_After_SHA1_mode = 7,	/*!&amp;lt; The input data is a digest of SHA1 and will not be hashed. */
	CRYS_RSA_After_SHA224_mode = 8,	/*!&amp;lt; The input data is a digest of SHA224 and will not be hashed. */
	CRYS_RSA_After_SHA256_mode = 9,	/*!&amp;lt; The input data is a digest of SHA256 and will not be hashed. */
	CRYS_RSA_After_SHA384_mode = 10,	/*!&amp;lt; The input data is a digest of SHA384 and will not be hashed. */
	CRYS_RSA_After_SHA512_mode = 11,	/*!&amp;lt; The input data is a digest of SHA512 and will not be hashed. */
	CRYS_RSA_After_HASH_NOT_KNOWN_mode = 12,    /*!&amp;lt; \internal used only for PKCS#1 Ver 1.5 - possible to perform verify operation without hash mode input, 
						the hash mode is derived from the signature.*/
	CRYS_RSA_HASH_NO_HASH_mode = 13,	/*!&amp;lt; Used for PKCS1 v1.5 Encrypt and Decrypt.*/
	CRYS_RSA_HASH_NumOfModes,		/*!&amp;lt; Maximal number of hash operations modes. */
	
	CRYS_RSA_HASH_OpModeLast  = 0x7FFFFFFF, /*! Reserved.*/

}CRYS_RSA_HASH_OpMode_t;   &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;By the way, since I have not seen this request before. Which part of PKCS requires raw data?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use cryptocell so sign data without a hash</title><link>https://devzone.nordicsemi.com/thread/228826?ContentTypeID=1</link><pubDate>Mon, 13 Jan 2020 14:03:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c0812fd-f626-450c-821a-3d198b864346</guid><dc:creator>Roelof</dc:creator><description>&lt;p&gt;As stated previously:&amp;nbsp;&lt;/p&gt;
[quote userid="81508" url="~/f/nordic-q-a/55458/how-to-use-cryptocell-so-sign-data-without-a-hash/228708"]Main issue: How can I sign (RSA) data of variable length without using a Hash before or after the signature?[/quote]
&lt;p&gt;I don&amp;#39;t want to compute a hash of the data, before or after. I just want to sign the raw data of variable length. My data is an asn.1 structure that should not be hashed. Is this possible?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use cryptocell so sign data without a hash</title><link>https://devzone.nordicsemi.com/thread/228825?ContentTypeID=1</link><pubDate>Mon, 13 Jan 2020 13:57:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f595154e-159b-41ac-a937-59e740867431</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;From the last&amp;nbsp;post, it seems clear you want to &lt;em&gt;sign&lt;/em&gt; the data, not encrypt it (it was initially unclear). In that case, the function you are looking for is probably&amp;nbsp;CRYS_RSA_PSS_SHA1_Sign(). You can refer to &amp;lt;SDK&amp;gt;\examples\crypto\nrf_cc310\rsa\main.c to see how it is done.&lt;/p&gt;
&lt;p&gt;Update:&amp;nbsp;remove the statement about hashing, since it is optional whether to provide a hash digest as input or just the data and let hashing be handled internally.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use cryptocell so sign data without a hash</title><link>https://devzone.nordicsemi.com/thread/228813?ContentTypeID=1</link><pubDate>Mon, 13 Jan 2020 13:36:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54e2b544-1477-4bcd-9ae5-63196e08ce63</guid><dc:creator>Roelof</dc:creator><description>&lt;p&gt;Both Functions mentioned requires the UserPubKey_ptr key as input. I want to sign with the Private key (Basically encrypt with the private key). Will&amp;nbsp;CRYS_RSA_PKCS1v15_Encrypt allow a private key as input?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use cryptocell so sign data without a hash</title><link>https://devzone.nordicsemi.com/thread/228812?ContentTypeID=1</link><pubDate>Mon, 13 Jan 2020 13:28:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:165e912a-db29-41d2-900f-f1a149c00a0a</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Maybe you are looking at the wrong api?&lt;/p&gt;
&lt;p&gt;There are two encypryption api&amp;#39;s in CC310 for RSA:&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;span&gt;RSA: CRYS_RSA_OAEP_Encrypt() and CRYS_RSA_PKCS1v15_Encrypt()&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Which to use depends on the variant you want to do, in general look at examples here:&lt;br /&gt;&lt;span&gt;examples\crypto\nrf_cc310\rsa\main.c&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use cryptocell so sign data without a hash</title><link>https://devzone.nordicsemi.com/thread/228708?ContentTypeID=1</link><pubDate>Mon, 13 Jan 2020 05:55:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d90b91e9-6a64-4e37-87e1-1a0ff0f3ea4e</guid><dc:creator>Roelof</dc:creator><description>&lt;p&gt;Is there any updates on this issue.&lt;/p&gt;
&lt;p&gt;Main issue: How can I sign (RSA) data of variable length without using a Hash before or after the signature?&lt;/p&gt;
&lt;p&gt;I want to use the mode CRYS_RSA_HASH_NO_HASH_mode - for signing, but this is not allowed for Signing&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use cryptocell so sign data without a hash</title><link>https://devzone.nordicsemi.com/thread/225095?ContentTypeID=1</link><pubDate>Thu, 12 Dec 2019 09:19:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1d2f07a-442d-48dd-8ebd-fe1bce356818</guid><dc:creator>Roelof</dc:creator><description>&lt;p&gt;Good day. Thank you for the response.&lt;/p&gt;
&lt;p&gt;Unfortunately these do not work. The standard RSA-PKCS does not do a hash function before or after the signing.&lt;/p&gt;
&lt;p&gt;The functions you are referring to require the input data to already be the length of the specific hash output and already be in hash format. Variable lengths of data can be expected as input for RSA-PKCS and not in the case of the functions &amp;quot;CRYS_RSA_After_xxx_mode&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use cryptocell so sign data without a hash</title><link>https://devzone.nordicsemi.com/thread/225092?ContentTypeID=1</link><pubDate>Thu, 12 Dec 2019 09:15:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9704098b-6691-4fa7-8a88-824477227d96</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Instead of using:&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; CRYS_RSA_HASH_SHA1_mode&amp;nbsp;=&amp;nbsp;1,&amp;nbsp; &amp;nbsp; /*!&amp;lt; The input data will be hashed with SHA1. */&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; CRYS_RSA_HASH_SHA224_mode&amp;nbsp;=&amp;nbsp;2,&amp;nbsp; /*!&amp;lt; The input data will be hashed with SHA224. */&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; CRYS_RSA_HASH_SHA256_mode&amp;nbsp;=&amp;nbsp;3,&amp;nbsp; /*!&amp;lt; The input data will be hashed with SHA256. */&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; CRYS_RSA_HASH_SHA384_mode&amp;nbsp;=&amp;nbsp;4,&amp;nbsp; /*!&amp;lt; The input data will be hashed with SHA384. */&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; CRYS_RSA_HASH_SHA512_mode&amp;nbsp;=&amp;nbsp;5,&amp;nbsp; /*!&amp;lt; The input data will be hashed with SHA512. */&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Try to use:&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; CRYS_RSA_After_SHA1_mode&amp;nbsp;=&amp;nbsp;7,&amp;nbsp; &amp;nbsp;/*!&amp;lt; The input data is a digest of SHA1 and will not be hashed. */&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; CRYS_RSA_After_SHA224_mode&amp;nbsp;=&amp;nbsp;8,&amp;nbsp;/*!&amp;lt; The input data is a digest of SHA224 and will not be hashed. */&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; CRYS_RSA_After_SHA256_mode&amp;nbsp;=&amp;nbsp;9,&amp;nbsp;/*!&amp;lt; The input data is a digest of SHA256 and will not be hashed. */&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; CRYS_RSA_After_SHA384_mode&amp;nbsp;=&amp;nbsp;10,&amp;nbsp; &amp;nbsp; /*!&amp;lt; The input data is a digest of SHA384 and will not be hashed. */&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; CRYS_RSA_After_SHA512_mode&amp;nbsp;=&amp;nbsp;11,&amp;nbsp; &amp;nbsp; /*!&amp;lt; The input data is a digest of SHA512 and will not be hashed. *&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>