
<!--Google 468*60橫幅廣告開始--><script type="text/javascript"><!-- google_ad_client = "pub-7343546549496470"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "image"; //2007-07-26: CSDN google_ad_channel = "6063905817"; google_color_border = "6699CC"; google_color_bg = "E6E6E6"; google_color_link = "FFFFFF"; google_color_text = "333333"; google_color_url = "AECCEB"; google_ui_features = "rc:6"; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script><!--Google 468*60橫幅廣告結束-->
keyczar 是這幾天 Google 放出來的 API ,其主要的功能為 加解密 與 數位簽署驗證. 它把一些實作的細節都隱藏起來,以及使用適當的預設值. 對於程式設計師的好處應該就是我們又可以把一些心力放在該注意的其它地方了!
查了一下 keyczar 是 BSD 授權,自己覺得以後有機會使用,所以花了一天的時間簡單寫了筆記跟嚐試去使用此 API . 目前實作仍卡關中! 囧rz
keyczar 我把玩至今的感覺(也許有錯! 請有興趣的人看官網比較準!), keyczar = console 介面 + JAVA API .
- console 介面: 利用命令列來產生管理 keyset .
- JAVA API : 程式設計師則用 API 來與 console 產生的檔案互動,做加密/解密/簽署/驗證 的功能.
目前我卡在 - 利用 console 產生出來的檔案格式似乎不標準,造成後續 API 無法正常運作,已經上討論區去問了! 希望不是我搞了個大笑話! Orz
以下為簡單概要筆記,建議不要全信,有問題看原本比較準! 之後問題解決也會將 測試程式碼片段 以及 解決方法 補上!
沒有 Keyzar 之前
- 開發者使用不適當的方式來加解密.
- 沒有辦法保護 Key Rotation.
- 將 Key Roration 以 hard-code 的方式編寫.
實作版本
JAVA
-
Keyczar
-
Keyczar(KeyczarReader inReader)
- KeyczarFileReader 從本地端讀取 KeySet .
- 開發者可以實作自己的 KeyczarReader.
-
Keyczar(KeyczarReader inReader)
- Keyczar(String inKeySetLocation)
-
Encrypter
- 將資料加密.
- 初始化需要傳入 crypting key set 的位置.
- 初始化傳入的 keyset 一定要有一個 primary key.
- 支援以UTF-8編碼的字串,位元組陣列 和 ByteBuffer .
-
Crypter
- 將加密資料解密.
- 初始化需要傳入 crypting key set 的位置.
- 初始化傳入的 keyset 可以包含能解密的 key,namely symmetric key 或 private key.
- 支援以WebSageBase64編碼的字串,位元組陣列 和 ByteBuffer .
-
Vertifier
- 驗證數位簽署.
- 初始化需要傳入任意 key set 的位置.
- 支援以WebSageBase64編碼的字串,位元組陣列 和 ByteBuffer .
-
Signer
- 替資料產生數位簽署.
- 初始化傳入的 keyset 可以包含能簽署的 key,namely symmetric key 或 private key.
- 初始化傳入的 keyset 一定要有一個 primary key.
- 支援以UTF-8編碼的字串,位元組陣列 和 ByteBuffer .
Python
C++ coming soon
使用 KeyczrTool
建立 KeyczrTool
-
使用 create 指令
- location
-
purpose
- crypt
- sign
- name
-
asymmetric
-
DSA
- 只支援 sign
-
RSA
- 支援 sign 跟 crypt
-
DSA
在 KeyczrTool 下建立 key
-
使用 addkey 指令
-
location
- primary
- active(預設)
- inactive
- status
- crypter
- size
-
location
在 KeyczrTool 下產生 public key
-
使用 pubkey 指令
- location
- destination
在 keyczrTool 下管理 key 的 status
-
promote
- active key -> primary key
- inactive key -> primary key
- 一組 keyset 中只會有一個 primary key.
-
demote
- primary key -> active key
- active key -> inactive key
-
revoke
- 只作用於 inactive key 上.
用 JAVA 實作遇的問題:
KeyczarTool 在哪裡?
keyczar05b-1.6.jar 解壓縮後在 org/keyczar 下.
怎麼執行 KeyczarTool ?
console 進入 keyczar 解壓目錄下.
執行 java org.keyczar.KeyczarTool (後面參數參考文件)
沒有 GsonBuilder .
至 http://code.google.com/p/google-gson/downloads/list 下載.
解壓縮後丟至 keyczar 相對應的位置下.
沒有 log4j .
至 http://logging.apache.org/log4j/1.2/download.html 下載.
解壓縮後丟至 keyczar 相對應的位置下.
資料來源
- Google Releases an Open Source Cryptography Toolkit
- Keyzar on Google Code
- http://www.keyczar.org/
- 回答我問題的 Ben Laurie 的部落格
<!--新Google 468*60橫幅廣告開始--><script type="text/javascript"><!-- google_ad_client = "pub-7343546549496470"; /* 468x60, 創建于 08-8-6 */ google_ad_slot = "7368701459"; google_ad_width = 468; google_ad_height = 60; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script><!--新Google 468*60橫幅廣告結束-->
<!--新Google 468x15 橫鏈接單元開始--><script type="text/javascript"><!-- google_ad_client = "pub-7343546549496470"; /* 468x15 橫鏈接單元 */ google_ad_slot = "5785741422"; google_ad_width = 468; google_ad_height = 15; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script><!--新Google 468x15 橫鏈接單元結束-->
<!-- Google Reader shared發布代碼開始 --><script type="text/javascript" src="http://www.google.com/reader/ui/publisher.js"></script><script type="text/javascript" src="http://www.google.com/reader/public/javascript/user/00697638153916680411/state/com.google/broadcast?n=5&callback=GRC_p(%7Bc%3A%22green%22%2Ct%3A%22%5Cu8FD9%5Cu4E9B%5Cu6587%5Cu7AE0%5Cu4E5F%5Cu503C%5Cu5F97%5Cu4E00%5Cu770B%22%2Cs%3A%22false%22%7D)%3Bnew%20GRC"></script><!-- Google Reader shared發布代碼結束 -->
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
