Concepts/OpenPGP Getting Started/uk: Difference between revisions
(Created page with "== Інші корисні статті ==") |
(тк) |
||
Line 22: | Line 22: | ||
== Захист ключів == | == Захист ключів == | ||
Якщо ви маєте справу з ключами, основним питанням є таке: наскільки безпечним та надійним є самі ключі та використання цих ключів? Найважливішим правилом у криптографії є не «зробити це ще безпечнішим», а «(1) Обдумайте, наскільки високий рівень безпеки вам потрібен. (2) Вирішіть, які технічні зусилля необхідні (нижня межа) та достатні (верхня межа) для встановлення цього рівня безпеки. (3) Виконайте строгий аналіз визначених вами правил (запишіть ці правила). (4) Якщо питання захисту стосується інших людей (так, зазвичай, і трапляється), надайте їм точні і безпечні відомості щодо обмежень у використанні та рівня безпеки ключа.» Більшу частину викладеної нижче статті присвячено безпеці і прозорості відомостей щодо захисту і призначення ключів. | |||
Nobody cracks keys by brute force attacks. That is (even for rather short keys, say 1024 bit) simply impossible for everyone beneath the level of a government agency of a "rich" country within the next decades. And it would not make sense: It's so easy to just steal them. With a huge probability the system which you are just using to read this text (if not printed...) is not very secure. De facto no system which is used for reading email or reading web pages is safe. Don't argue, just accept this. If you don't you probably just compromise yourself. A key is never more secure than the least secure system on which it has been used (this, of course, includes: created). And it is more secure than the least secure system on which it has been stored just by its passphrase which is no protection against a brute force attack if it is either not really random or less than about 16 characters long (for small and capital letters and digits). | Nobody cracks keys by brute force attacks. That is (even for rather short keys, say 1024 bit) simply impossible for everyone beneath the level of a government agency of a "rich" country within the next decades. And it would not make sense: It's so easy to just steal them. With a huge probability the system which you are just using to read this text (if not printed...) is not very secure. De facto no system which is used for reading email or reading web pages is safe. Don't argue, just accept this. If you don't you probably just compromise yourself. A key is never more secure than the least secure system on which it has been used (this, of course, includes: created). And it is more secure than the least secure system on which it has been stored just by its passphrase which is no protection against a brute force attack if it is either not really random or less than about 16 characters long (for small and capital letters and digits). |
Revision as of 13:07, 12 July 2013
Вступ
Під час створення ключа ви приймаєте декілька технічних та організаційних рішень (знаєте ви про це чи ні), які значно впливають на захист та придатність до користування вашого ключа, а отже і на строк придатності цього ключа. Деякі з цих рішень після створення ключа вже не можна змінити. З декількох причин бажано, щоб звичайні ключі, навіть доволі незахищені, принаймні у основній частині мали довгий строк придатності.
Отже, у цій статті ми познайомимося з важливими аспектами створення ключів. Стаття допоможе вам створити якісний ключ, яким ви зможете користуватися багато років. У цій статті ви знайдете лише загальні поняття, з якими варто бути ознайомленими. У ній не викладено покрокової процедури створення ключа, оскільки саму процедуру слід відокремити: спочатку слід чітко зрозуміти основні принципи, спланувати ваші дії, а потім вже виконати необхідні приготування. Якщо ви вже знайомі з усіма потрібними поняттями і усе вже спланували, зверніться до статті, присвяченої створенню ключа OpenPGP.
Перші кроки
Створити якийсь ключ для того, щоб побавитися ним, доволі просто. Але якщо такий ключ буде прийнято і підтверджено іншими користувачами, ви ризикуєте у майбутньому втратити результати вашої роботи. Вашою метою має бути створення одного або декількох довготермінових ключів. Найкращою порадою у такій ситуації буде: якщо це можливо, не намагайтеся усе зробити самостійно. Якщо можна, зверніться до експертів, людей, які вже міняли власний ключ і багато чому з цього навчилися. Користуйтеся безпечними системами для створення ключів, зберігайте основний ключ у безпечному місці без доступу з мережі і вкажіть для основного ключа і підключів строк дії (цей строк не повинен перевищувати року). Визначте правила поводження з ключами (у цих правилах має бути описано захист і прийоми користування основним ключем і підключами) і дотримуйтеся цих правил. Якщо ви виконуєте сертифікацію ключів сторонніх осіб до створення правил сертифікації, не виконуєте повної сертифікації (сертифікації для мережі довіри), замість цього виконайте локальне підписування (лише для вас). Уникайте виконання нових для вас дій, доки добре не зрозумієте їх наслідки.
І пам’ятайте:
- Усе, що здається зручним (принаймні на перший погляд), становить загрозу вашим даним.
- Чим більше захисту, тим краще. Зважайте на можливі наслідки (ця порада працює і у зворотний бік: чим важливішими є дані, тим кращим має бути захист).
Вітаємо вас у світі криптографії!
Захист ключів
Якщо ви маєте справу з ключами, основним питанням є таке: наскільки безпечним та надійним є самі ключі та використання цих ключів? Найважливішим правилом у криптографії є не «зробити це ще безпечнішим», а «(1) Обдумайте, наскільки високий рівень безпеки вам потрібен. (2) Вирішіть, які технічні зусилля необхідні (нижня межа) та достатні (верхня межа) для встановлення цього рівня безпеки. (3) Виконайте строгий аналіз визначених вами правил (запишіть ці правила). (4) Якщо питання захисту стосується інших людей (так, зазвичай, і трапляється), надайте їм точні і безпечні відомості щодо обмежень у використанні та рівня безпеки ключа.» Більшу частину викладеної нижче статті присвячено безпеці і прозорості відомостей щодо захисту і призначення ключів.
Nobody cracks keys by brute force attacks. That is (even for rather short keys, say 1024 bit) simply impossible for everyone beneath the level of a government agency of a "rich" country within the next decades. And it would not make sense: It's so easy to just steal them. With a huge probability the system which you are just using to read this text (if not printed...) is not very secure. De facto no system which is used for reading email or reading web pages is safe. Don't argue, just accept this. If you don't you probably just compromise yourself. A key is never more secure than the least secure system on which it has been used (this, of course, includes: created). And it is more secure than the least secure system on which it has been stored just by its passphrase which is no protection against a brute force attack if it is either not really random or less than about 16 characters long (for small and capital letters and digits).
It is perfectly OK to use OpenPGP on such insecure systems (i.e. normal computers). You and your communication partners(!) just have to be aware of the security level. The next security level are smartcards. You cannot steal a key from a smartcard (you can abuse it nonetheless if you control the system to which the smardcard is connected). The next level after smartcards are secure systems: Unconnect your harddisk, all USB sticks (and the like) and the network, boot from a secure medium like a Linux live DVD (from a trusted source, of course!). Use high security keys in such a secure environment only (and maybe even limited to safe document formats like plain text or HTML).
Main key and subkeys
Most OpenPGP keys have at least one subkey (all have exactly one main key). You usually need not care about this difference; your application (or rather the base application, usually GnuPG) selects the right one automatically. The main key is the one which the key fingerprint refers to and only the main key can certify: your own subkeys and user IDs and the user IDs of other keys. The subkeys can do everything else (mainly decryption and signing) if you configure them so. The reason the difference between these key types is mentioned here is that this is very important for key generation: You can separate the secret main key from the secret subkeys (with GnuPG; this is not part of the OpenPGP standard!). The subkeys can be replaced later, the main key cannot (that would be a new key not just a modified key). Thus if you create an offline main key at key generation which you protect by a very hard passphrase, store at least the passphrase securely and use the main key (and its passphrase) in secure environments only then you can keep this key "forever" (say 20 years). This is important for everyday keys. High security keys don't really need this separation (usually don't need subkeys at all). You should create one subkey for each capability you need: encryption, signing, and maybe authentication (for SSH).
Secure environment
The key shall be generated in a secure environment and the secret main key shall never be used in an insecure environment. But what is a secure environment? That depends on the security level of the key. If you want to secure nuclear weapons release codes you will have higher requirements to the hardware and software involved than if you just want to keep your affair secret.
At any rate you should not boot from your harddisk (ideally disconnect it) but from some trustworthy read-only medium. This is usually a Linux CD/DVD. You should pay attention to getting this from a safe source. Just downloading some image from the Internet and burning it to a blank doesn't make a secure environment up. In general a pressed CD/DVD (e.g. from a magazine or bought on its own) seems more trustworthy.
Hardware is important, too. If you use a system which was known in advance to be used for the generation of valuable keys somebody might like the idea to add a hardware keylogger. Pay attention to rather trivial attacks: Prevent everybody else from seeing you typing your passphrase (even through windows) and from seeing your slip of paper with the passphrase. Reboot the system after key creation or (better) power it off and keep it so for three minutes.
User IDs
User IDs are formally just arbitrary strings but expected to consist of a name, an optional comment, and an email address. This structure allows email software to find the suitable key for a recipient address (which most programs require you to confirm for obvious reasons). An OpenPGP public key (more precise: certificate) must have a user ID but can have as many as you like. Thus you can use the same key for several email addresses (which makes sense only if these addresses shall be used at the same security level). Combining addresses has advantages and disadvantages. The main advantage is that you need less keys and thus you and others have less work with certifications. The main disadvantages are that you can revoke user IDs but they keep visible forever and that such a combined key allows to make a trivial connections between different roles of you which you may not want connected: private person, business, other organizations (associations, political parties, whatever). You may want to keep these groups separate. And there are even reasons to keep addresses from the same group separate: reputable addresses ([email protected]), anonymous addresses ([email protected]), fun addresses ([email protected]). It also may be that you have no reason to ever use OpenPGP with certain addresses; such addresses should not be part of a user ID, of course. The decision to add an address to a key and publish that key is forever. But it is easy to add an address later. Thus consider this well before you generate the key. In case of doubt start with fewer addresses.
It makes sense to have a special user ID without an email address. With most email addresses you cannot be sure to have them forever. If you revoke a User ID because you don't use the address any more then you lose all the certifications for this user ID. But you will never lose your name (even if you marry or the like there is usually little reason to revoke that user ID). So you keep the certifications for this ID at any rate. And you can use the comment for this ID for a statement about the key itself: "everyday key with secure offline main key and key policy"
Key type and length
The well supported key types are DSA (signatures only), ElGamal (encryption only) and RSA (both); ECDSA (elliptic curves) is going to be added soon. GnuPG offers the creation of keys with a length from 1024 to 4096 bit. This is the current situation (2013).
The differences in security, execution time, signature size, and being required or just considered optional by the standard (rfc4880) are irrelevant for most scenarios. The one relevant difference is: The g10 smartcard supports RSA only. Thus generate an RSA key unless you have concrete and good reason for a different decision. 1024 bit keys are considered breakable by certain well known government agencies today or in the near future. 2048 bit keys are considered safe for decades. But remember: These well known agencies would not waste their time and money by computing your key. They would steal your key. Thus if you want a larger key in order to be safe against this kind of opponent then make sure that they cannot steal it. This obviously requires profound knowledge, discipline and probably some money. The practical reasons against very long keys are: Commonly used versions of GnuPG do not support keys with more than 2048 or 3072 bit respectively length. Operations with asymmetric keys are costly in general. To make it worse: Operation with twice the key size take eight times as long. And it takes long to generate huge keys. For mobile devices this CPU load can become a problem.
Thus: Unless you have concrete and good reason for a different decision stick to 2048 bit (at least for everyday keys).
Key expiration
The main key can set (and change) the expiration date for itself and its subkeys. The only "disadvantage" of an expiration date for others is that they have to update the key to keep it usable. But keys shall be updated regularly anyway so you may consider that an advantage as well. The main advantage of an expiration date (for the main key, too) is that keys which are not used any more can easily be recognized as such. The "official" way is another, of course. If a key is abandoned then a revocation certificate should be published. But this may be impossible (key or passphrase lost and no certificate created before (or lost, too)) or you may simply forget to do so (or to publish it everywhere). The "right" validity period is a compromise between reducing disturbance by expired keys (on both sides; remember that you need a secure environment to change the expiration date with an offline main key) and the time which a key still appears valid. One year may be a good choice.
Revocation certificate
A revocation certificate is a file (or print-out) which you may create preventively to later revoke a whole key in case you have no access to the secret main key any more. This is a huge advantage if you have not just lost access to the key but someone else has! The disadvantage is: You should protect this file / print-out similarly well as the secret main key itself. It can be serious damage if you have only one (suitable) key, need it urgently and someone else destroys it right then. Obviously a main key revocation is forever (cannot be superseded by a newer self-signature).
If you (or someone else you really trust) have another key which is secure enough then you may add this key as a designated revoker to yours (you need not publish this). A designated revoker can revoke another key. Of course, the signature for the designated revoker must be available when this shall be used. If you have not given it to the other person and lost it together with your key then this is useless. If you prefer security over availability then you may make friend A your designated revoker, encrypt this signature for friend B and ask friend C to store it.
Passphrase, safe storage, and backup
You should think about where you will store the passphrase for the main key and the revocation certificate file or print-out. Secure passphrases are hard to remember. You will most probably have to write it down. You really should not use a passphrase you have ever typed on an insecure system (and, of course, you really should not ever do so in the future). You should choose something like rsbBwNl137LcWP33RI: 18 chars consisting of lower and upper case letters and digits. Don't use special chars or umlauts. You gain little security (if you cannot remember 18 random chars then you probably cannot remember 15, too) but may get problems if you are ever forced to use the key on a rescue system (text mode Linux) with "wrong" keyboard settings. You improve security if you memorize a part of the passphrase and write down just the rest or if you write down both halves of it separately and store them in different places (one in your wallet, the other one at home). But if you store an 18 chars passphrase in two parts and an attacker gets one of them then the remaining 9 chars are not a secure protection any more. If you have created a revocation certificate then you have to store that in a safe place, too.
And, of course, you should have reliable backups of your key. It is nice if you need not be afraid that somebody has stolen your key but it is probably very unpleasant if you cannot decrypt your data any more. If you have a secure passphrase then you may even put a backup of your secret main key on your web site.
Key policy and policy URL
You should write a document (plain text or HTML) which describes the intended usage and security of your key and (maybe added later) your criteria for certifying the keys of other people. You can write one or more URLs at which this document can (later) be found into the key and in every signature you make. This key component is called a policy URL. It is a good idea to publish only user ID signatures which contain this policy URL(s). It is important that the users of your key can check whether a certain document belongs to a policy URL (the web server download is not safe, not even over HTTPS). Thus you should change the policy URL every time you change the document and mention the URL well visible in the document. You may use this pattern: http://yourdomain.example.org/openpgp/0x12345678__policy.1.html This document should have a detached signature (or a cleartext signature if it is plain text) by the offline main key. You should link the detached signature from the document.
Preferred key server
Like the policy URL a key server URL can be written into the key. You should decide which key server shall be authoritative for your key so that the users of your key know where they have to search for the "officially current version" of your key. This should be the key server which you upload key updates to first. This should be the one you configure in the GnuPG config file (--keyserver
) for key searches and uploads. This address should mainly be available for a long time and have only few and short outages. You may even use your own web site: http://yourdomain.example.org/openpgp/0x12345678.asc
Availability is improved if a server pool (with the same DNS address) is used. If you have no better idea then you may use hkp://pool.sks-keyservers.net or one of the more local pools hkp://eu.pool.sks-keyservers.net (Europe), hkp://na.pool.sks-keyservers.net (North America) or hkp://sa.pool.sks-keyservers.net (South America). See http://sks-keyservers.net/overview-of-pools.php
Algorithm preferences
You can also write into your key (for others) and into your config file (for your actions) in which order you prefer the cipher and digest algorithms. You should do this before you generate the key (this is easier than changing it afterwards). It makes sense to avoid SHA-1. Please be aware that you cannot prevent that GnuPG creates SHA-1 signatures with your key (because that is the only digest required by the standard). You may want to put lines like these in your gpg.conf (due to design flaws AES256 and AES192 are less secure than AES(128) is currently believed to be...):
personal-cipher-preferences AES,AES256,AES192,CAST5,3DES personal-digest-preferences SHA512,SHA384,SHA256,SHA224,RIPEMD160,SHA1 cert-digest-algo SHA512 default-preference-list AES,AES256,AES192,CAST5,3DES,SHA512,SHA384,SHA256,SHA224,RIPEMD160,SHA1,ZLIB,BZIP2,ZIP