PKCS
PKCS 鍏ㄧО鏄?Public-Key Cryptography Standards 錛屾槸鐢?RSA 瀹為獙瀹や笌鍏跺畠瀹夊叏緋葷粺寮鍙戝晢涓轟績榪涘叕閽ュ瘑鐮佺殑鍙戝睍鑰屽埗璁㈢殑涓緋誨垪鏍囧噯銆?/p>
What is PKCS? http://www.rsa.com/rsalabs/node.asp?id=2308
PKCS 鐩墠鍏卞彂甯冭繃 15 涓爣鍑嗭細
錛?錛塒KCS#1錛歊SA鍔犲瘑鏍囧噯銆侾KCS#1瀹氫箟浜哛SA鍏挜鍑芥暟鐨勫熀鏈牸寮忔爣鍑嗭紝鐗瑰埆鏄暟瀛楃鍚嶃傚畠瀹氫箟浜嗘暟瀛楃鍚嶅浣曡綆楋紝鍖呮嫭寰呯鍚嶆暟鎹拰絳懼悕鏈韓鐨勬牸寮忥紱瀹冧篃瀹氫箟浜哖SA鍏?縐侀挜鐨勮娉曘?br />
錛?錛塒KCS#2錛氭秹鍙婁簡RSA鐨勬秷鎭憳瑕佸姞瀵嗭紝榪欏凡琚茍鍏KCS#1涓?br />
錛?錛塒KCS#3錛欴iffie-Hellman瀵嗛挜鍗忚鏍囧噯銆侾KCS#3鎻忚堪浜嗕竴縐嶅疄鐜癉iffie- Hellman瀵嗛挜鍗忚鐨勬柟娉曘?br />
錛?錛塒KCS#4錛氭渶鍒濇槸瑙勫畾RSA瀵嗛挜璇硶鐨勶紝鐜板凡緇忚鍖呭惈榪汸KCS#1涓?br />
錛?錛塒KCS#5錛氬熀浜庡彛浠ょ殑鍔犲瘑鏍囧噯銆侾KCS#5鎻忚堪浜嗕嬌鐢ㄧ敱鍙d護鐢熸垚鐨勫瘑閽ユ潵鍔犲瘑8浣嶄綅緇勪覆騫朵駭鐢熶竴涓姞瀵嗙殑8浣嶄綅緇勪覆鐨勬柟娉曘侾KCS#5鍙互鐢ㄤ簬鍔犲瘑縐侀挜錛屼互渚夸簬瀵嗛挜鐨勫畨鍏ㄤ紶杈擄紙榪欏湪PKCS#8涓弿榪幫級銆?br />
錛?錛塒KCS#6錛氭墿灞曡瘉涔﹁娉曟爣鍑嗐侾KCS#6瀹氫箟浜嗘彁渚涢檮鍔犲疄浣撲俊鎭殑X.509璇佷功灞炴ф墿灞曠殑璇硶錛堝綋PKCS#6絎竴嬈″彂甯冩椂錛孹.509榪樹笉鏀寔鎵╁睍銆傝繖浜涙墿灞曞洜姝よ鍖呮嫭鍦╔.509涓級銆?br />
錛?錛塒KCS#7錛氬瘑鐮佹秷鎭娉曟爣鍑嗐侾KCS#7涓轟嬌鐢ㄥ瘑鐮佺畻娉曠殑鏁版嵁瑙勫畾浜嗛氱敤璇硶錛屾瘮濡傛暟瀛楃鍚嶅拰鏁板瓧淇″皝銆侾KCS#7鎻愪緵浜嗚澶氭牸寮忛夐」錛屽寘鎷湭鍔犲瘑鎴栫鍚嶇殑鏍煎紡鍖栨秷鎭佸凡灝佽錛堝姞瀵嗭級娑堟伅銆佸凡絳懼悕娑堟伅鍜屾棦緇忚繃絳懼悕鍙堢粡榪囧姞瀵嗙殑娑堟伅銆?br />
錛?錛塒KCS#8錛氱閽ヤ俊鎭娉曟爣鍑嗐侾KCS#8瀹氫箟浜嗙閽ヤ俊鎭娉曞拰鍔犲瘑縐侀挜璇硶錛屽叾涓閽ュ姞瀵嗕嬌鐢ㄤ簡PKCS#5鏍囧噯銆?br />
錛?錛塒KCS#9錛氬彲閫夊睘鎬х被鍨嬨侾KCS#9瀹氫箟浜哖KCS#6鎵╁睍璇佷功銆丳KCS#7鏁板瓧絳懼悕娑堟伅銆丳KCS#8縐侀挜淇℃伅鍜孭KCS#10璇佷功絳懼悕璇鋒眰涓鐢ㄥ埌鐨勫彲閫夊睘鎬х被鍨嬨傚凡瀹氫箟鐨勮瘉涔﹀睘鎬у寘鎷珽-mail鍦板潃銆佹棤鏍煎紡濮撳悕銆佸唴瀹圭被鍨嬨佹秷鎭憳瑕併佺鍚嶆椂闂淬佺鍚嶅壇鏈紙counter signature錛夈佽川璇㈠彛浠ゅ瓧鍜屾墿灞曡瘉涔﹀睘鎬с?br />
錛?0錛塒KCS#10錛氳瘉涔﹁姹傝娉曟爣鍑嗐侾KCS#10瀹氫箟浜嗚瘉涔﹁姹傜殑璇硶銆傝瘉涔﹁姹傚寘鍚簡涓涓敮涓璇嗗埆鍚嶃佸叕閽ュ拰鍙夌殑涓緇勫睘鎬э紝瀹冧滑涓璧瘋璇鋒眰璇佷功鐨勫疄浣撶鍚嶏紙璇佷功綆$悊鍗忚涓殑PKIX璇佷功璇鋒眰娑堟伅灝辨槸涓涓狿KCS#10錛夈?br />
錛?1錛塒KCS#11錛氬瘑鐮佷護鐗屾帴鍙f爣鍑嗐侾KCS#11鎴栤淐ryptoki鈥濅負鎷ユ湁瀵嗙爜淇℃伅錛堝鍔犲瘑瀵嗛挜鍜岃瘉涔︼級鍜屾墽琛屽瘑鐮佸鍑芥暟鐨勫崟鐢ㄦ埛璁懼瀹氫箟浜嗕竴涓簲鐢ㄧ▼搴忔帴鍙o紙API錛夈傛櫤鑳藉崱灝辨槸瀹炵幇Cryptoki鐨勫吀鍨嬭澶囥傛敞鎰忥細Cryptoki瀹氫箟浜嗗瘑鐮佸嚱鏁版帴鍙o紝浣嗗茍鏈寚鏄庤澶囧叿浣撳浣曞疄鐜拌繖浜涘嚱鏁般傝屼笖Cryptoki鍙鏄庝簡瀵嗙爜鎺ュ彛錛屽茍鏈畾涔夊璁懼鏉ヨ鍙兘鏈夌敤鐨勫叾浠栨帴鍙o紝濡傝闂澶囩殑鏂囦歡緋葷粺鎺ュ彛銆?br />
錛?2錛塒KCS#12錛氫釜浜轟俊鎭氦鎹㈣娉曟爣鍑嗐侾KCS#12瀹氫箟浜嗕釜浜鴻韓浠戒俊鎭紙鍖呮嫭縐侀挜銆佽瘉涔︺佸悇縐嶇瀵嗗拰鎵╁睍瀛楁錛夌殑鏍煎紡銆侾KCS#12鏈夊姪浜庝紶杈撹瘉涔﹀強瀵瑰簲鐨勭閽ワ紝浜庢槸鐢ㄦ埛鍙互鍦ㄤ笉鍚岃澶囬棿縐誨姩浠栦滑鐨勪釜浜鴻韓浠戒俊鎭?br />
錛?3錛塒DCS#13錛氭き鍦嗘洸綰垮瘑鐮佹爣鍑嗐侾KCS#13鏍囧噯褰撳墠姝e湪瀹屽杽涔嬩腑銆傚畠鍖呮嫭妞渾鏇茬嚎鍙傛暟鐨勭敓鎴愬拰楠岃瘉銆佸瘑閽ョ敓鎴愬拰楠岃瘉銆佹暟瀛楃鍚嶅拰鍏挜鍔犲瘑錛岃繕鏈夊瘑閽ュ崗瀹氾紝浠ュ強鍙傛暟銆佸瘑閽ュ拰鏂規鏍囪瘑鐨凙SN.1璇硶銆?br />
錛?4錛塒KCS#14錛氫吉闅忔満鏁頒駭鐢熸爣鍑嗐侾KCS#14鏍囧噯褰撳墠姝e湪瀹屽杽涔嬩腑銆備負浠涔堥殢鏈烘暟鐢熸垚涔熼渶瑕佸緩绔嬭嚜宸辯殑鏍囧噯鍛紵PKI涓敤鍒扮殑璁稿鍩烘湰鐨勫瘑鐮佸鍑芥暟錛屽瀵嗛挜鐢熸垚鍜孌iffie-Hellman鍏變韓瀵嗛挜鍗忓晢錛岄兘闇瑕佷嬌鐢ㄩ殢鏈烘暟銆傜劧鑰岋紝濡傛灉鈥滈殢鏈烘暟鈥濅笉鏄殢鏈虹殑錛岃屾槸鍙栬嚜涓涓彲棰勬祴鐨勫彇鍊奸泦鍚堬紝閭d箞瀵嗙爜瀛﹀嚱鏁板氨涓嶅啀鏄粷瀵瑰畨鍏ㄤ簡錛屽洜涓哄畠鐨勫彇鍊艱闄愪簬涓涓緝灝忎簡鐨勫煎煙涓傚洜姝わ紝瀹夊叏浼殢鏈烘暟鐨勭敓鎴愬浜嶱KI鐨勫畨鍏ㄦ瀬涓哄叧閿?br />
錛?5錛塒KCS#15錛氬瘑鐮佷護鐗屼俊鎭娉曟爣鍑嗐侾KCS#15閫氳繃瀹氫箟浠ょ墝涓婂瓨鍌ㄧ殑瀵嗙爜瀵硅薄鐨勯氱敤鏍煎紡鏉ュ榪涘瘑鐮佷護鐗岀殑浜掓搷浣滄с傚湪瀹炵幇PKCS#15鐨勮澶囦笂瀛樺偍鐨勬暟鎹浜庝嬌鐢ㄨ璁懼鐨勬墍鏈夊簲鐢ㄧ▼搴忔潵璇撮兘鏄竴鏍風殑錛屽敖綆″疄闄呬笂鍦ㄥ唴閮ㄥ疄鐜版椂鍙兘鎵鐢ㄧ殑鏍煎紡涓嶅悓銆侾KCS#15鐨勫疄鐜版壆婕斾簡緲昏瘧瀹剁殑瑙掕壊錛屽畠鍦ㄥ崱鐨勫唴閮ㄦ牸寮忎笌搴旂敤紼嬪簭鏀寔鐨勬暟鎹牸寮忛棿榪涜杞崲銆?/p>
X509
X.509鏄父瑙侀氱敤鐨勮瘉涔︽牸寮忋傛墍鏈夌殑璇佷功閮界鍚堜負Public Key Infrastructure (PKI) 鍒跺畾鐨?ITU-T X509 鍥介檯鏍囧噯銆俋.509鏄浗闄呯數淇¤仈鐩?鐢典俊錛圛TU-T錛夐儴鍒嗘爣鍑嗗拰鍥介檯鏍囧噯鍖栫粍緇囷紙ISO錛夌殑璇佷功鏍煎紡鏍囧噯銆備綔涓篒TU-ISO鐩綍鏈嶅姟緋誨垪鏍囧噯鐨勪竴閮ㄥ垎錛孹.509鏄畾涔変簡鍏挜璇佷功緇撴瀯鐨勫熀鏈爣鍑嗐?988騫撮嬈″彂甯冿紝1993騫村拰1996騫翠袱嬈′慨璁€傚綋鍓嶄嬌鐢ㄧ殑鐗堟湰鏄疿.509 V3錛屽畠鍔犲叆浜嗘墿灞曞瓧孌墊敮鎸侊紝榪欐瀬澶у湴澧炶繘浜嗚瘉涔︾殑鐏墊椿鎬с俋.509 V3璇佷功鍖呮嫭涓緇勬寜棰勫畾涔夐『搴忔帓鍒楃殑寮哄埗瀛楁錛岃繕鏈夊彲閫夋墿灞曞瓧孌碉紝鍗充嬌鍦ㄥ己鍒跺瓧孌典腑錛孹.509璇佷功涔熷厑璁稿緢澶х殑鐏墊椿鎬э紝鍥犱負瀹冧負澶у鏁板瓧孌墊彁渚涗簡澶氱緙栫爜鏂規.
PKCS#7 甯哥敤鐨勫悗緙鏄細 .P7B .P7C .SPC
PKCS#12 甯哥敤鐨勫悗緙鏈夛細 .P12 .PFX
X.509 DER 緙栫爜(ASCII)鐨勫悗緙鏄細 .DER .CER .CRT
X.509 PAM 緙栫爜(Base64)鐨勫悗緙鏄細 .PEM .CER .CRT
.cer/.crt鏄敤浜庡瓨鏀捐瘉涔︼紝瀹冩槸2榪涘埗褰㈠紡瀛樻斁鐨勶紝涓嶅惈縐侀挜銆?br />.pem璺焎rt/cer鐨勫尯鍒槸瀹冧互Ascii鏉ヨ〃紺恒?br />pfx/p12鐢ㄤ簬瀛樻斁涓漢璇佷功/縐侀挜錛屼粬閫氬父鍖呭惈淇濇姢瀵嗙爜錛?榪涘埗鏂瑰紡
p10鏄瘉涔﹁姹?br />p7r鏄疌A瀵硅瘉涔﹁姹傜殑鍥炲錛屽彧鐢ㄤ簬瀵煎叆
p7b浠ユ爲鐘跺睍紺鴻瘉涔﹂摼(certificate chain)錛屽悓鏃朵篃鏀寔鍗曚釜璇佷功錛屼笉鍚閽ャ?br />
涓 鐢╫penssl鍒涘緩CA璇佷功鐨凴SA瀵嗛挜(PEM鏍煎紡)錛?br />openssl genrsa -des3 -out ca.key 1024
浜岀敤openssl鍒涘緩CA璇佷功(PEM鏍煎紡,鍋囧鏈夋晥鏈熶負涓騫?錛?br />openssl req -new -x509 -days 365 -key ca.key -out ca.crt -config openssl.cnf
openssl鏄彲浠ョ敓鎴怐ER鏍煎紡鐨凜A璇佷功鐨勶紝鏈濂界敤IE灝哖EM鏍煎紡鐨凜A璇佷功杞崲鎴怐ER鏍煎紡鐨凜A璇佷功銆?/p>
涓?x509鍒皃fx
pkcs12 -export 鈥搃n keys/client1.crt -inkey keys/client1.key -out keys/client1.pfx
鍥?PEM鏍煎紡鐨刢a.key杞崲涓篗icrosoft鍙互璇嗗埆鐨刾vk鏍煎紡銆?br />聽 pvk -in ca.key -out ca.pvk -nocrypt -topvk
浜?PKCS#12 鍒?PEM 鐨勮漿鎹?br />openssl pkcs12 -nocerts -nodes -in cert.p12 -out private.pem
楠岃瘉 openssl pkcs12 -clcerts -nokeys -in cert.p12 -out cert.pem
鍏?浠?PFX 鏍煎紡鏂囦歡涓彁鍙栫閽ユ牸寮忔枃浠?(.key)
openssl pkcs12 -in mycert.pfx -nocerts -nodes -out mycert.key
涓?杞崲 pem 鍒板埌 spc
openssl crl2pkcs7 -nocrl -certfile venus.pem聽 -outform DER -out venus.spc
鐢?-outform -inform 鎸囧畾 DER 榪樻槸 PAM 鏍煎紡銆備緥濡傦細
openssl x509 -in Cert.pem -inform PEM -out cert.der -outform DER
鍏?PEM 鍒?PKCS#12 鐨勮漿鎹紝
openssl pkcs12 -export -in Cert.pem -out Cert.p12 -inkey key.pem
瀵嗛挜搴撴枃浠舵牸寮忋怟eystore銆?/strong>
聽鏍煎紡聽聽聽聽 :聽 JKS
聽鎵╁睍鍚嵚?: .jks/.ks
聽鎻忚堪聽聽聽聽 : 銆怞ava Keystore銆戝瘑閽ュ簱鐨凧ava瀹炵幇鐗堟湰錛宲rovider涓篠UN
聽鐗圭偣聽聽聽聽 :聽 瀵嗛挜搴撳拰縐侀挜鐢ㄤ笉鍚岀殑瀵嗙爜榪涜淇濇姢
聽
聽鏍煎紡聽聽聽聽 :聽 JCEKS
聽鎵╁睍鍚嵚?:聽 .jce
聽鎻忚堪聽聽聽聽 :聽銆怞CE Keystore銆戝瘑閽ュ簱鐨凧CE瀹炵幇鐗堟湰錛宲rovider涓篠UN JCE
聽鐗圭偣聽聽聽聽 :聽 鐩稿浜嶫KS瀹夊叏綰у埆鏇撮珮錛屼繚鎶eystore縐侀挜鏃墮噰鐢═ripleDES
聽
聽鏍煎紡聽聽聽聽 :聽 PKCS12
聽鎵╁睍鍚嵚?:聽 .p12/.pfx
聽鎻忚堪聽聽聽聽 :聽銆怭KCS #12銆戜釜浜轟俊鎭氦鎹㈣娉曟爣鍑?br />聽鐗圭偣聽聽聽聽 :聽 1銆佸寘鍚閽ャ佸叕閽ュ強鍏惰瘉涔?br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽2銆佸瘑閽ュ簱鍜岀閽ョ敤鐩稿悓瀵嗙爜榪涜淇濇姢
聽
聽鏍煎紡聽聽聽聽 :聽 BKS
聽鎵╁睍鍚嵚?: .bks
聽鎻忚堪聽聽聽聽 :聽 Bouncycastle Keystore銆戝瘑閽ュ簱鐨凚C瀹炵幇鐗堟湰錛宲rovider涓築C
聽鐗圭偣聽聽聽聽 :聽 鍩轟簬JCE瀹炵幇
聽
聽鏍煎紡聽聽聽聽 : UBER
聽鎵╁睍鍚嵚?: .ubr
聽鎻忚堪聽聽聽聽 : 銆怋ouncycastle UBER Keystore銆戝瘑閽ュ簱鐨凚C鏇村畨鍏ㄥ疄鐜扮増鏈紝provider涓築C
璇佷功鏂囦歡鏍煎紡銆怌ertificate銆?/strong>
鏍煎紡聽聽聽聽聽聽聽聽聽聽:聽 DER
鎵╁睍鍚嵚犅犅犅犅犅犅?聽 .cer/.crt/.rsa
鎻忚堪聽聽聽聽聽聽聽聽聽聽: 銆怉SN .1 DER銆戠敤浜庡瓨鏀捐瘉涔?
鐗圭偣聽聽聽聽聽聽聽聽聽聽:聽 涓嶅惈縐侀挜銆佷簩榪涘埗
鏍煎紡聽聽聽聽聽聽聽聽聽聽:聽 PKCS7
鎵╁睍鍚嵚犅犅犅犅犅犅? .p7b/.p7r
鎻忚堪聽聽聽聽聽聽聽聽聽聽: 銆怭KCS #7銆戝姞瀵嗕俊鎭娉曟爣鍑?
鐗圭偣聽聽聽聽聽聽聽聽聽聽: 1銆乸7b浠ユ爲鐘跺睍紺鴻瘉涔﹂摼錛屼笉鍚閽?br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 2銆乸7r涓篊A瀵硅瘉涔﹁姹傜鍚嶇殑鍥炲錛屽彧鑳界敤浜庡鍏?
鏍煎紡聽聽聽聽聽聽聽聽聽聽:聽 CMS
鎵╁睍鍚嵚犅犅犅犅犅犅?聽 .p7c/.p7m/.p7s
鎻忚堪聽聽聽聽聽聽聽聽聽聽: 銆怌ryptographic Message Syntax銆?
鐗圭偣聽聽聽聽聽聽聽聽聽聽: 1銆乸7c鍙繚瀛樿瘉涔?br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽2銆乸7m錛歴ignature with enveloped data
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 3銆乸7s錛氭椂闂存埑絳懼悕鏂囦歡
聽
鏍煎紡聽聽聽聽聽聽聽聽聽聽:聽 PEM
鎵╁睍鍚嵚犅犅犅犅犅犅? .pem
鎻忚堪聽聽聽聽聽聽聽聽聽聽: 銆怭rintable Encoded Message銆?
鐗圭偣聽聽聽聽聽聽聽聽聽 : 1銆佽緙栫爜鏍煎紡鍦≧FC1421涓畾涔夛紝鍏跺疄PEM鏄怭rivacy-Enhanced Mail銆戠殑綆鍐欙紝浣嗕粬涔熷悓鏍峰箍娉涜繍鐢ㄤ簬瀵嗛挜綆$悊
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽2銆丄SCII鏂囦歡
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽3銆佷竴鑸熀浜巄ase 64緙栫爜
鏍煎紡聽聽聽聽聽聽聽聽聽: 聽PKCS10
鎵╁睍鍚嵚犅犅犅犅犅?聽.p10/.csr
鎻忚堪聽聽聽聽聽聽聽聽 : 銆怭KCS #10銆戝叕閽ュ姞瀵嗘爣鍑嗐怌ertificate Signing Request銆?br />鐗圭偣聽聽聽聽聽聽聽聽 :聽 1銆佽瘉涔︾鍚嶈姹傛枃浠?br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 2銆丄SCII鏂囦歡
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 3銆丆A絳懼悕鍚庝互p7r鏂囦歡鍥炲
鏍煎紡聽聽聽聽聽聽聽聽 :聽 SPC
鎵╁睍鍚嵚犅犅犅犅?:聽.pvk/.spc
鎻忚堪聽聽聽聽聽聽聽聽 : 銆怱oftware Publishing Certificate銆?
鐗圭偣聽聽聽聽聽聽聽聽 :聽 寰蔣鍏徃鐗規湁鐨勫弻璇佷功鏂囦歡鏍煎紡錛岀粡甯哥敤浜庝唬鐮佺鍚嶏紝鍏朵腑
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 1銆乸vk鐢ㄤ簬淇濆瓨縐侀挜
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 2銆乻pc鐢ㄤ簬淇濆瓨鍏挜
杞嚜http://blog.csdn.net/hansel/article/details/4447631
X509鍜孭KCS鐨勫叧緋昏璁猴細http://topic.csdn.net/u/20071015/18/37a2bffb-2354-493e-b5a9-b96ab28063ae.html
http://www.carillon.ca/library/pkitutorial.php
In recent years, two of the main hurdles encountered when using data networks for collaborative work and the transmission of sensitive information have been, in no particular order:
Various techniques have been available to solve those issues, usually through the use of cryptographical tools. The basic approach is to use a specific mathematical formula (the cipher) into which a series of numbers (the secret key) can be plugged; when this formula is applied to some data (called the plaintext), this data is turned into an unintelligible mass of characters (called the ciphertext).
The transformation of plaintext into ciphertext is called encryption; the reverse process is called decryption.
Only someone who knows what cipher and what secret key were used can return the ciphertext back to the original plaintext. Usually, the cipher is well-known, but the secret key is, well, secret.
The cipher must guarantee two things:
Let's put this in an example. May we introduce Alice and Bob, who are trying to exchange information. But in the shadows lurks Eve, the Eve-ildoer who is trying to Eve-sdrop on the information being exchanged between Alice and Bob.
Alice and Bob, who know each other and plan on exchanging data in a secure fashion, meet face-to-face and choose a secret key. At a later time, when Alice wants to send Bob some confidential data, she takes that plaintext and applies the cipher to it, using the pre-arranged secret key. The resulting ciphertext is sent via the network to Bob, including some information, such as which cipher was used. Bob receives the ciphertext, applies the reverse cipher with the secret key, and obtains the original plaintext.
Our eavesdropping Eve also manages to get a copy of the ciphertext; however, she can't make sense of its contents. Even knowing which cipher was used, without the secret key, she can't decrypt the captured data back to its original plaintext form.
This takes care of data confidentiality; if Alice wants only specific people to access a certain piece of encrypted information, she can give the secret key to only those people. But how does it address data integrity? It doesn't, at least not directly. If something interferes with the ciphertext during transit, decrypting it will generate unintelligible data. However, as far as Bob is concerned, the original plaintext might not have been intelligible data in the first place, so he has no proof that the data was or wasn't altered.
Another technique, data hashing, will help Alice with that objective.
To guarantee data integrity, a new mathematical tool is needed. A hash function is another (and very different) mathematical formula through which our plaintext will be processed, producing a fixed-length result called a hash sum. This hash function presents the following characteristics:
How is that useful? Imagine Alice produces a hash sum for a specific plaintext and then encrypts the hash sum with the secret key she shares with Bob. If she joins that encrypted hash sum with her original message, Bob can decrypt the hash sum sent by Alice and then calculate his own hash sum from the plaintext. If both hash sums match, it means the retrieved plaintext is indeed identical to what Alice sent. If the hash sums differ, the message was modified at some point.
If Eve intercepts the message and tries to modify it, she can't create a new encrypted hash sum that will correspond to the modified message, since she doesn't have the secret key. Therefore, data integrity can be achieved.
So, it would seem that encryption and data hashing solve our confidentiality and integrity issues. There is, however, a major problem with this approach. Our initial premise is that Alice and Bob meet before any data exchange to establish a secret key. What if Alice and Bob are halfway around the world? That complicates the meeting. What if Alice wants to communicate securely with Bob, but also with Charlie, Dennis and Fred? That forces her to hold additional meetings. And if Bob also wants to communicate with Charlie, Dennis and Fred? Even more meetings. And what if they all need to communicate now, without having met before?
Enter public-key cryptography.
A more complex but extremely useful approach is asymmetric cryptography, also known as public-key cryptography (yes, this is the same "Public Key" as in "Public Key Infrastructure"!), which will now be the focus of our interest.
Public-key cryptography revolves around the use of a mathematically linked pair of keys, one designated public and the other designated private. This mathematical linkage is such that plaintext encrypted using one of the keys can only be decrypted using the other key. A specific individual has her own pair of keys, keeping the private key absolutely private and the public key as public as possible.
How does this apply to our quandary? If Alice has in hand her own public key (PubA), her own private key (PrivA), and Bob's public key (PubB), she can do the following:
Upon receiving this message, Bob, who should have in his posession his own public key (PubB), his own private key (PrivB), and Alice's public key (PubA), can do the following:
Bob therefore obtains the plaintext and, if the hash sums are the same, the guarantee that it hasn't been altered in transit.
What if Eve intercepts the message sent by Alice? Eve has her own public key (PubE), her own private key (PrivE), Alice's public key (PubA) and Bob's public key (PubB). Unfortunately for her, this doesn't do her any good; since she doesn't have Bob's private key, she can't retrieve the plaintext, and since she doesn't have Alice's private key, she can't modify the message and encrypt a new hash sum.
Data confidentiality and integrity are therefore assured, without forcing everybody to meet beforehand. All that's needed is a way to distribute public keys.
Before we tackle the issue of distribution, there's an interesting concept that deserves a little detour. When Alice applies a hash function to a plaintext and encrypts the obtained hash sum with her private key, the result is called a digital signature.
A digital signature guarantees two things:
The latter is an important point - the digital signature proves the document was indeed sent by Alice, and Alice cannot claim she didn't send it.
Of course, this all takes for granted that Alice is the only one who can access her private key. If a private key is compromised, i.e. if it falls into someone else's hands, the associated public key becomes useless. Worse, it becomes dangerous, because people might still think it valid and believe that something signed with Alice's private key indeed comes from Alice. In the other direction, plaintext encrypted with Alice's public key will actually be readable by everyone who has access to Alice's private key. The simple moral of this is - private keys are an extremely sensitive piece of information, and must be kept utterly safe, at all times.
There is one major problem left. For the system to work, Alice must be absolutely sure that the public key with which she encrypts the plaintext is indeed Bob's. Should she be tricked in using Eve's, for example, Eve would then be able to decrypt the ciphertext and access the plaintext.
Or, if what Bob thinks is Alice's public key is actually Eve's, Eve can sign a document that Bob will believe is coming from Alice.
Therefore, while the public keys per se are not meant to be secret, it is imperative that the person the public key is associated with be ascertained. This could be done through a face-to-face meeting, as we initially did at the beginning of this conversation; however, this is no more practical now than it was back then.
Back to the drawing board? Not quite. There might be an acceptable compromise.
What if Alice and Bob have a common friend, named Charlie. Charlie travels a lot, meets a lot of people, and is an all-around pleasant and very, very reliable individual. If, during his travels, Charlie has met with Alice and exchanged public keys with her, he now has a copy of Alice's public key that he is sure belongs to Alice, and Alice has a copy of Charlie's public key that she is sure belongs to Charlie. The next time Charlie meets with Bob, they can not only exchange public keys, but if Bob really trusts Charlie, he can also accept his copy of Alice's public key with assurance that it is indeed Alice's.
Charlie can even take this one step further; he can take Bob's public key, digitally sign it with his own private key, and send this to Alice. Alice is sure of her copy of Charlie's public key, so she can trust that this indeed comes from Charlie. And if she trusts Charlie to be a thorough and reliable individual, she can also accept what she has just received as Bob's public key.
If Charlie also meets Dennis and Fred, this process can be expanded even further. All the people who trust Charlie to do a good job can now have reliable access to each other's public key, just by meeting Charlie once.
There's a specific name for a public key digitally signed by someone many people trust; it is called a certificate. Usually, there is also some additional information enclosed, such as the name, organisation, email address, etc. of the person whose public key is contained within the certificate.
And now to the core of the matter...
So what is a Public Key Infrastructure or PKI? It is a system designed to allow the creation and distribution of those certificates. In technical terms, it is the combination of:
In other words, it's a Charlie. It's someone who participants can have direct contact with, who can validate people's identity and accept their public key, who can generate certificates for them and who can distribute those certificates. It's someone who is extremely meticulous and absolutely trustworthy, and who people trust.
What makes it even more useful is that PKIs can trust each other, under very specific conditions; when this occurs, a PKI's participants (or subscribers, as they are officially called) can access and trust the certificates of the other PKI's subscribers.
While it may not seem that way, the technical side of a PKI is fairly simple. What is complex is that to be of any use, it must be trusted by its subscribers, and must be deserving of that trust. This comes through the creation of very specific and very strict sets of rules and guidelines, that must be transparent, auditable and followed at all times. Those rules are enumerated in a document called the Certificate Policy (or CP), which states how the PKI must function.
So in a nutshell, a PKI is a system that guarantees that a specific public key belongs to a specific identity. What can be done with it? A lot.
For a more detailed yet still very reader-friendly look at PKI and its underlying concepts, we encourage you to take a look at our world-renowned PKI Fingerpuppet Theatre.