|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-712DF59D-FAE1-592E-82A6-4E323676F5B8" xml:lang="en"><title>Symmetric |
|
13 ciphers -- guide</title><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <ul> |
|
15 <li id="GUID-A66ADA26-979E-5B4A-824F-29C182AFCB24"><p> <xref href="GUID-712DF59D-FAE1-592E-82A6-4E323676F5B8.dita#GUID-712DF59D-FAE1-592E-82A6-4E323676F5B8/GUID-6F996812-1D73-509B-9CED-DD672728D597">What are symmetric ciphers?</xref> </p> </li> |
|
16 <li id="GUID-46055BED-B538-5B49-BD43-A2E3AA3368E8"><p> <xref href="GUID-712DF59D-FAE1-592E-82A6-4E323676F5B8.dita#GUID-712DF59D-FAE1-592E-82A6-4E323676F5B8/GUID-BDF6E245-AE19-55D6-89ED-BCBE0FCF006B">Block and stream ciphers</xref> </p> </li> |
|
17 <li id="GUID-5B9FF3E3-3732-5A75-B429-23B318C0CCBF"><p> <xref href="GUID-712DF59D-FAE1-592E-82A6-4E323676F5B8.dita#GUID-712DF59D-FAE1-592E-82A6-4E323676F5B8/GUID-A4E43A90-A66F-5868-BD94-DA709B75431B">Types of symmetric algorithms supported</xref> </p> </li> |
|
18 <li id="GUID-26930CA6-C2AF-58DB-87AB-803481AA3DED"><p> <xref href="GUID-712DF59D-FAE1-592E-82A6-4E323676F5B8.dita#GUID-712DF59D-FAE1-592E-82A6-4E323676F5B8/GUID-66E8AD5D-A9FF-51E3-897D-D5EC3D66903A">Base classes and their derived classes</xref> </p> </li> |
|
19 </ul> |
|
20 <section id="GUID-6F996812-1D73-509B-9CED-DD672728D597"><title>What are symmetric |
|
21 ciphers? </title> <p>Symmetric algorithms are much faster than asymmetric |
|
22 algorithms so are used to encrypt and decrypt large amounts of data. In an |
|
23 informal setting, symmetric ciphers can be thought of as a mapping of some |
|
24 plaintext to ciphertext, via some well-known transformation function, dependent |
|
25 on a single secret key. Symmetric algorithms have the property that if a message |
|
26 is encrypted under a given key, it can only be decrypted using the same key: </p> <fig id="GUID-FDB090BE-13DA-5941-8403-F42C3DF880BF"> |
|
27 <title> The diagram above shows the encryption and decryption process using: |
|
28 a symmetric algorithm; a plaintext message, M; a symmetric key, K; and the |
|
29 ciphertext, K(M).</title> |
|
30 <image href="GUID-669190F8-3BE9-58FC-B689-00F06FDAD74D_d0e592173_href.png" placement="inline"/> |
|
31 </fig> <p>So it provides secrecy and also some kind of authentication. If |
|
32 Alice encrypts a secret using a key known only to her, then only she can access |
|
33 the secrets. </p><p>It can also be used for communication: if Alice shares |
|
34 a key with Bob (and only Bob), then she can encrypt her messages with that |
|
35 key and send it to Bob, and only Bob can decrypt them. In this case the key |
|
36 is a 'shared secret' enabling private communications. </p><p>There are two |
|
37 basic types of symmetric ciphers: <xref href="GUID-712DF59D-FAE1-592E-82A6-4E323676F5B8.dita#GUID-712DF59D-FAE1-592E-82A6-4E323676F5B8/GUID-BDF6E245-AE19-55D6-89ED-BCBE0FCF006B">block |
|
38 ciphers and stream ciphers</xref>. </p> </section> |
|
39 <section id="GUID-BDF6E245-AE19-55D6-89ED-BCBE0FCF006B"><title>Block and stream |
|
40 ciphers</title> <ul> |
|
41 <li id="GUID-D0F3A85C-2DB3-57BE-A12B-102943DB68C9"><p> <b> Stream ciphers</b> are |
|
42 essentially functions that are initialized with a key, and output a stream |
|
43 of pseudorandom bits, this 'keystream' is typically XOR-ed with the plaintext |
|
44 to generate the ciphertext. So they encrypt a bit of plaintext at a time. |
|
45 They map an <i>n</i> -bit stream of plaintext to a <i>n</i> -bit stream of |
|
46 ciphertext. </p> </li> |
|
47 <li id="GUID-25F8F07B-C60E-5B6D-9224-B7E4E89D15A3"><p> <b>Block ciphers</b> encrypt |
|
48 several bits at once in a fixed-size block. That is, they map <i>m</i> <i>n</i> -bit |
|
49 blocks of plaintext to <i>m</i> <i>n</i> -bit blocks of ciphertext. The cipher |
|
50 and its mode of operation define the block size: the plaintext is split up |
|
51 into appropriately-sized blocks and each block is fed into the cipher. </p> <p>There |
|
52 are two issues here that don't occur with stream ciphers: </p> <ul> |
|
53 <li id="GUID-2C88F6DF-B8F8-5DF3-8955-03DA02371DEC"><p> <b> padding</b>: the |
|
54 total size of the input has to be a multiple of the block size, so the plaintext |
|
55 usually has to be padded to fit (see the class <xref href="GUID-FFD4A90B-CCF7-33D2-802A-A44E2434FAE9.dita"><apiname>CPadding</apiname></xref>). |
|
56 Optionally, instead of padding out a plaintext message to fit in a block, |
|
57 block ciphers allow buffering of partial input blocks until the remainder |
|
58 of the block is given as input. (see <xref href="GUID-CFF1BCCA-5D07-5B8A-9363-AD11EEEAB485.dita#GUID-CFF1BCCA-5D07-5B8A-9363-AD11EEEAB485/GUID-3393A9D6-CB78-5740-B250-F9C1C26C59BD">How |
|
59 does buffering work within the symmetric cipher framework?</xref> and <xref href="http://www.rsasecurity.com/rsalabs/node.asp?id=2129" scope="external">PKCS#7</xref>). </p> </li> |
|
60 <li id="GUID-EE6C6890-8F7E-50AD-AEB9-10C43E931DE9"><p> <b>combining blocks</b>: |
|
61 if you just encrypt each plaintext block with the cipher and then concatenate |
|
62 the ciphertext blocks, then an attacker who knows something about the structure |
|
63 can switch the order of the ciphertext blocks to alter the meaning of the |
|
64 message. For example, if the plaintext includes instructions like 'pay £XXX |
|
65 to account holder ABC, reference number YYY', then an attacker could replace |
|
66 the encryption of XXX with some of the encryption of YYY. This leads to other |
|
67 techniques for combining blocks, called modes, where, for example, the output |
|
68 of the last block is fed into the input for the next one. So, the output is |
|
69 not just a function of that plaintext block and key, but is a function of |
|
70 that plaintext block, the key, and all preceding ciphertext blocks (see <xref href="GUID-CFF1BCCA-5D07-5B8A-9363-AD11EEEAB485.dita#GUID-CFF1BCCA-5D07-5B8A-9363-AD11EEEAB485/GUID-71CD8B41-219D-5D07-8C99-47D68668A880">Symmetric |
|
71 Modes</xref>). </p> </li> |
|
72 </ul> </li> |
|
73 </ul> <p>Both stream ciphers and block ciphers are provided by the API with |
|
74 a similar interface. Block ciphers usually need padding for non completed |
|
75 blocks. The API allows the user to choose the padding to be added at the end |
|
76 of the last encrypted block or to be checked and removed from the last decrypted |
|
77 block. </p> </section> |
|
78 <section id="GUID-A4E43A90-A66F-5868-BD94-DA709B75431B"><title>Types of symmetric |
|
79 algorithms supported</title> <p>The following symmetric algorithms are supported: </p> <table id="GUID-25F43544-4556-544B-B010-76B0E091B80C"> |
|
80 <tgroup cols="3"><colspec colname="col0"/><colspec colname="col1"/><colspec colname="col2"/> |
|
81 <thead> |
|
82 <row> |
|
83 <entry>Symmetric algorithm</entry> |
|
84 <entry>Type</entry> |
|
85 <entry>Specified in:</entry> |
|
86 </row> |
|
87 </thead> |
|
88 <tbody> |
|
89 <row> |
|
90 <entry><p>AES (Advanced Encryption Standard) </p> </entry> |
|
91 <entry><p>Block cipher </p> </entry> |
|
92 <entry><p> <xref href="http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf" scope="external">FIPS-197</xref> </p> </entry> |
|
93 </row> |
|
94 <row> |
|
95 <entry><p>DES (Data Encryption Standard) </p> </entry> |
|
96 <entry><p>Block cipher </p> </entry> |
|
97 <entry><p> <xref href="http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf" scope="external">FIPS 46-3</xref> </p> </entry> |
|
98 </row> |
|
99 <row> |
|
100 <entry><p>3DES (Triple Data Encryption Standard) </p> </entry> |
|
101 <entry><p>Block cipher </p> </entry> |
|
102 <entry><p> <xref href="http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf" scope="external">FIPS 46-3</xref> </p> </entry> |
|
103 </row> |
|
104 <row> |
|
105 <entry><p>RC2-128 </p> </entry> |
|
106 <entry><p>Block cipher </p> </entry> |
|
107 <entry><p> <xref href="ftp://ftp.rfc-editor.org/in-notes/rfc2268.txt" scope="external">RFC |
|
108 2268</xref> </p> </entry> |
|
109 </row> |
|
110 <row> |
|
111 <entry><p>ARC4 ('alleged' RC4) </p> </entry> |
|
112 <entry><p>Stream cipher </p> </entry> |
|
113 <entry><p>the internet and a posting to sci.crypt in 1994. </p> </entry> |
|
114 </row> |
|
115 </tbody> |
|
116 </tgroup> |
|
117 </table> </section> |
|
118 <section id="GUID-66E8AD5D-A9FF-51E3-897D-D5EC3D66903A"><title>Base classes |
|
119 and their derived classes</title> <p>The symmetric cipher API is used by Networking |
|
120 (TLS/IPSec). </p> <p> <xref href="GUID-F4E08165-A654-3D32-8FED-7ED54BDAD88B.dita"><apiname>CSymmetricCipher</apiname></xref> is the abstract |
|
121 base class that allows a client to use the supported symmetric algorithms |
|
122 listed above. It allows clients to encrypt and decrypt without having to know |
|
123 anything about which encryption algorithm is currently in use. </p> <p>The |
|
124 PKCS5 API (the <codeph>TPKCS5KDF</codeph> class, also see <xref href="GUID-0C7CDC47-6B42-5A20-BED8-086DA81D272E.dita">Password |
|
125 Based Encryption</xref>) offers Key Derivation Support that allows the derivation |
|
126 of deterministic arbitrary length byte streams from an input string. The output |
|
127 byte stream is generated using multiple iterations of a SHA-1 message digest |
|
128 (<codeph>CSHA1</codeph>) and is suitable for use as a cryptographic symmetric |
|
129 key. </p> <p>The diagrams below show the main classes used in symmetric cipher |
|
130 framework. Blue dotted arrows indicate that a class is contained or used by |
|
131 another class. The arrows are labelled with the variable(s) through which |
|
132 the pointed class is accessible. The colour of the boxes indicates the type |
|
133 of Symbian class, i.e., <codeph>M</codeph>, <codeph>C</codeph>, <codeph>R</codeph> or <codeph>T</codeph> class. |
|
134 For detailed information on each component see the Cryptography API Reference |
|
135 material. </p> <p><b><xref href="GUID-F4E08165-A654-3D32-8FED-7ED54BDAD88B.dita"><apiname>CSymmetricCipher</apiname></xref> and derived classes</b> </p> <fig id="GUID-B11D8EE9-F078-57B2-9453-3ABF1FC0AAA1"> |
|
136 <title>The inheritance diagram shows the <codeph>CSymmetricCipher</codeph> abstract |
|
137 base class and its derived abstract classes <codeph>CBufferedTransformation</codeph> and <codeph>CStreamCipher</codeph> used |
|
138 for block and stream ciphers respectively. Also shown are the following derived |
|
139 classes: <codeph>CBufferedDecryptor</codeph>, <codeph>CBufferedEncryptor</codeph>, <codeph>CARC4</codeph>, |
|
140 and <codeph>CNullCipher</codeph>.</title> |
|
141 <image href="GUID-5F72210C-1636-584D-9D89-987D25136975_d0e592479_href.png" placement="inline"/> |
|
142 </fig> <p><b><xref href="GUID-CFDA5321-EE13-3203-8DED-71E69D4469BD.dita"><apiname>CBlockTransformation</apiname></xref> and derived classes</b> </p> <fig id="GUID-EB7BFBBF-D41C-5A3A-AA53-3F5BDA019C2A"> |
|
143 <title>The inheritance diagram above shows the <xref href="GUID-CFDA5321-EE13-3203-8DED-71E69D4469BD.dita"><apiname>CBlockTransformation</apiname></xref> abstract |
|
144 base class used for block ciphers. Also shown are the following derived classes: <xref href="GUID-436C3EBE-FC60-3760-A3BA-D8DF8FA5B8AF.dita"><apiname>CBlockChainingMode</apiname></xref>, <xref href="GUID-C65A1F55-A8D2-3393-8DC1-35656017E2B8.dita"><apiname>CModeCBCEncryptor</apiname></xref>, <xref href="GUID-7D5FBD2C-83A0-351A-96B3-C5C54FE525E6.dita"><apiname>CModeCBCDecryptor</apiname></xref>, <xref href="GUID-1C18ED2F-085F-3C3E-A93E-5FD37461E440.dita"><apiname>CDES</apiname></xref>, <xref href="GUID-E7401D77-AD0E-3B8F-A7CC-23ADA5151DB6.dita"><apiname>CDESEncryptor</apiname></xref>, <xref href="GUID-249270AC-907B-3E46-AFDB-131FDC6F612A.dita"><apiname>CDESDecryptor</apiname></xref>, <xref href="GUID-90A671B0-756E-3773-8429-6441D1594F4B.dita"><apiname>C3DES</apiname></xref>, <xref href="GUID-B931DBB9-4484-33FD-9E94-6F256ABD5C68.dita"><apiname>C3DESEncryptor</apiname></xref>, <xref href="GUID-C693C22D-04C5-3C9E-8605-0EA90F723AF3.dita"><apiname>C3DESDecryptor</apiname></xref>, <xref href="GUID-BEE18CDE-CFB6-3116-9FAE-046780D4D006.dita"><apiname>CRC2</apiname></xref>, <xref href="GUID-19F20C86-5722-3A35-B17D-3830D18CC7FC.dita"><apiname>CRC2Encryptor</apiname></xref>, <xref href="GUID-E6FD8DF9-258B-39BC-8C39-ABF7434A29B5.dita"><apiname>CRC2Decryptor</apiname></xref>, <xref href="GUID-B0AEE24A-91A6-335E-AD64-C9DDCC1F81A9.dita"><apiname>CRijndael</apiname></xref>, <xref href="GUID-AE1A9AC0-DB79-3C62-AA23-896812F25F14.dita"><apiname>CAESEncryptor</apiname></xref>, and <xref href="GUID-51666543-0256-3E0D-BF5F-8716753C5921.dita"><apiname>CAESDecryptor</apiname></xref>.</title> |
|
145 <image href="GUID-7461BD6A-F50B-5E14-8995-CF3F2D8F5F14_d0e592559_href.png" placement="inline"/> |
|
146 </fig> <p id="GUID-A8F9A25F-B83E-5FE7-840F-4DCF246D3D96"><b>CPadding and derived |
|
147 classes</b> </p> <fig id="GUID-648F7604-A3C6-57EB-9B34-7F8079549D9C"> |
|
148 <title>Above is an inheritance diagram showing the CPadding abstract base |
|
149 class used with block ciphers. Also shown are the following derived classes: <xref href="GUID-B7090C61-ECC7-3E8A-8D19-75C9170B0135.dita"><apiname>CPaddingPKCS7</apiname></xref>, <xref href="GUID-3150ECC9-CF8E-3890-91CD-87F5EBCE550E.dita"><apiname>CPaddingPKCS1Encryption</apiname></xref>, <xref href="GUID-F845CB30-7ABE-3EB6-B1B9-C72581897D0C.dita"><apiname>CRSAPKCS1v15Encryptor</apiname></xref>, <xref href="GUID-57C40DCA-8340-38B5-9777-2863C8F88B59.dita"><apiname>CPaddingNone</apiname></xref>, <xref href="GUID-723F64D1-01C5-3A03-B987-0FB862EE8EDE.dita"><apiname>CPaddingPKCS1Signature</apiname></xref>, |
|
150 and <xref href="GUID-CC2347BE-3272-3DDF-8BDD-B44F5C0026B3.dita"><apiname>CPaddingSSLv3</apiname></xref></title> |
|
151 <image href="GUID-0FD02CAD-B687-50C0-8E44-74ED9B4A936E_d0e592595_href.png" placement="inline"/> |
|
152 </fig> </section> |
|
153 </conbody></concept> |