Kerckhoffs’ principles – Why should I make my cipher public? As I understand it, the less people know about the internals of my protocol or cipher, the more secure the protocol is. However Kerckhoffs's principle states that


  A cryptosystem should be secure even if everything about the system, except the key, is public knowledge.


To be more precise, it's the 2nd principle that states


  It must not be required to be secret, and it must be able to fall into the hands of the enemy without inconvenience;


Of course I understand why I should keep the key secret, but publishing my protocol's internals seems counter-intuitive. Why should I do it? Wouldn't that give the advantage to the attacker?
Actually, that wikipedia article you mention in your question already answers your question: 


  It is moderately common for companies and sometimes even standards bodies as in the case of the CSS encryption on DVDs – to keep the inner workings of a system secret. Some argue this "security by obscurity" makes the product safer and less vulnerable to attack. A counter argument is that keeping the innards secret may improve security in the short term, but in the long run only systems that have been published and analyzed should be trusted.


But let's dive in deeper anyway...

Kerckhoffs’ principles

For reference purposes, here is Kerckhoffs' original text (from Auguste Kerckhoffs, "La cryptographie militaire", Journal des sciences militaires, vol. IX, pp. 5–38 "II. DESIDERATA DE LA CRYPTOGRAPHIE MILITAIRE.", Jan. 1883):


  


In plain text, this reads:


  1° Le système doit être matériellement, sinon mathématiquement, indéchiffrable ;
  2° Il faut qu’il n’exige pas le secret, et qu’il puisse sans inconvénient tomber entre les mains de l’ennemi ;
  3° La clef doit pouvoir en être communiquée et retenue sans le secours de notes écrites, et être changée ou modifiée au gré des correspondants ;
  4° Il faut qu’il soit applicable à la correspondance télégraphique ;
  5° Il faut qu’il soit portatif, et que son maniement ou son fonctionnement n’exige pas le concours de plusieurs personnes ;
  6° Enfin, il est nécessaire, vu les circonstances qui en commandent l’application, que le système soit d’un usage facile, ne demandant ni tension d’esprit, ni la connaissance d’une longue série de règles à observer.


And here is my English translation for your convenience:


  
  The system must be physically, if not mathematically, indecipherable;  
  It must not require secrecy, and may not cause inconveniences when it falls into the hands of the enemy;
  The key must be communicated and retained without the aid of written notes, and be changed or modified at the discretion of correspondents;  
  It must be applicable to telegraphic correspondence;  
  It must be portable, and its usage and its operation does not require the assistance of several people;  
  Finally, it is necessary, given the circumstances that control the application, that the system is easy to use, requiring no mental strain, or the knowledge of a long series of rules to be observed. 
  


The enemy knows the system

Kerckhoffs' surviving principle nr. 2 (of initially six design principles for military ciphers) says nothing else than that you have to look at the security of your crypto under the aspects of "the enemy knows the algorithm" and maybe even "the enemy carries the message". The well-known Claude Shannon once simplified Kerckhoffs' principle as: "the enemy knows the system".

The "advantage to the attacker" one might be thinking about when deciding to keep an algo secret, would practically be "just a matter of time for the attacker to find out" since keeping the algorithm secret would be relying on "security through obscurity", which we all know to be a bad idea.

The idea of Kerckhoffs' principle is that if any part of a cryptosystem (except the individual secret key) has to be kept secret then the cryptosystem is not secure. That's because, if the simple act of disclosing some detail of the system were to make it suddenly insecure, then you've got a problem on your hands. The gold standard for any secret keeping system is that all its details should be able to be made public without compromising the security of the system. The security relies on the system itself, not the secrecy of the system.

A good example of why Kerckhoffs' principle makes sense would be the German Enigma machine used in WWII. By stealing machines, the Allies knew everything there was to know about how the Enigma machine worked; they only had to read the manuals, use the code-books and look at the way the machine was constructed and worked. After all, they had a working example in their hands. Throughout history, there are countless examples of secret algorithms falling into wider knowledge, variously through espionage, betrayal and reverse engineering. And on occasion, ciphers have been reconstructed through pure deduction. For example, the German Lorenz cipher and the Japanese Purple code, and a variety of classical schemes.

Therefore, the core idea of Kerckhoffs' 2nd principle is still applied today. The security of HTTPS, SSL and ciphers like AES or RSA rely on the strength of the algorithm, not on keeping them secret. The algorithms are all published and detailed standards have been created which everyone can take a look at. The only "secret" is the key that's chosen when you connect to a secure web site (that's done automatically and randomly by your browser and the server) or when you encrypt a document using a program like GPG.

To recap: why publish the cryptographic algorithm?

Not publishing a cryptographic algorithm doesn’t make much sense as it's just a matter of time for the attacker to find out how your crypto works. Security gain can therefore only be of temporary nature.

On the other hand, publishing of a cryptographic algorithm tends to build trust because the publication of its internals allows the verification of related security claims.

In fact, you can even transport the answer to “why publish the cryptographic algorithm” down to a much simpler level: the security of the lock of your home's door does not depend on keeping the lock hidden and its mechanisms secret. Its security comes from you keeping the key safe. That is one of the most simple examples of Kerckhoffs' 2nd principle in action.

One of many examples

To provide an example, let me point you to — what I would call — an "über-publication": "The Design of Rijndael: AES - The Advanced Encryption Standard" by Joan Daemen and Vincent Rijmen.



This book, written by the designers of the block cipher, presents Rijndael (more commonly known as AES) from scratch. The underlying mathematics and the wide trail strategy as the basic design idea are explained in detail and the basics of differential and linear cryptanalysis are reworked. Subsequent chapters review all known attacks against the Rijndael structure and deal with implementation and optimization issues. Finally, other ciphers related to Rijndael are presented.

As you might have noticed: it didn't hurt the security of Rijndael/AES in any way that all its internals were published. Quite the contrary – related publications only resulted in more confidence in the cipher.