基於雜湊訊息驗證碼的一次性密碼演算法

本頁使用了標題或全文手工轉換
維基百科,自由的百科全書

基於HMAC的一次性密碼演算法(英語:HMAC-based One-time Password algorithm,HOTP)是一種基於雜湊訊息驗證碼(HMAC)的一次性密碼(OTP)演算法,同時也是開放驗證提案的基礎(OATH)。

HOTP在2005年由IETF發佈在RFC 4226標準文件中,定義了演算法的同時附帶有一例基於Java的實現。自此之後,世界上許多公司接納了HOTP演算法,它也成為了可以自由使用的開源標準

演算法[編輯]

HOTP演算法在驗證時使用對稱生成的人類可讀密碼(演算法中也稱為「運算值」),每個密碼僅在一次驗證中有效。這種一次性屬性直接來自於計數器數值的單次使用。

任何有意願使用HOTP的一方都必須定義一系列對於驗證器而言已明確的參數,無論是否這些參數是否可以被驗證器接受,都可能包含:

  • 加密雜湊演算法,記為H(預設為SHA-1
  • 伺服器分發的金鑰,記為K,可以是任意長度的字串,但必須保密。
  • HOTP運算值長度,記為d,(數值從6至10均可,預設為6,建議為6至8)

HOTP驗證中的雙方都會運算最終數值,驗證器會將本地運算結果與被驗證方提供的結果進行比對。

由於驗證雙方都分別各自自增計數器數值,驗證器的計數器可能落後於被驗證方,因此定義用於重新同步的協定是意義的。RFC 4226標準中給出了相關建議,但並不做強制要求。為解決可能的不同步,驗證器會使用當前計數器值起嘗試用連續多個值(稱為窗口)進行運算,如果驗證成功,則驗證器將對應的計數器值更新為當前值,無需被驗證方做任何操作。窗口大小由參數指定。[1]:7,8

上述建議是出於避免HOTP數值驗證過程中出現卡死,但是同時也使得數值相對偏小,暴力破解攻擊也因此變得容易。有一個建議是在驗證失敗幾次之後就鎖定驗證過程,或者每次驗證失敗時都(以線性方式)延長下次操作時間。

專有的硬件金鑰通常會提供六位驗證碼,也就是d的預設值。金鑰截留最長長度為31位元,由於公式中 ≈ 9.3,也就是d的最大值取10,因此第十位數值可能的取值也就更少,為0、1或者2(也就對應多出的0.3這個小數數值)。

雙重重新導向驗證[編輯]

在驗證之後,驗證器可以通過運算得出下一個HOTP數值來執行驗算,得出返回的數值之後,接受驗證的一方將計算HOTP數值進行驗證。值得注意的是,這一過程中的計數器數值需要保證同步。

HOTP運算值[編輯]

HOTP運算值設計上是人類可讀的,它是一個位數為d的十進制數字(開頭的0不可忽略):

HOTP運算值 = HOTP(K, C) mod 10d

上述公式也說明運算值是最小位數為d的十進制數值。

HOTP本質上是雜湊訊息驗證碼(HMAC)的計數器截留,計數器數值記為C(伺服器分發金鑰記為K,雜湊函數記為H)。

HOTP(K, C) = truncate(HMACH(K, C))

截取首先是位於最小的四位MAC數值當中,截得之後用於作為回呼數值,記為i

truncate(MAC) = extract31(MAC, MAC[(19 × 8) + 4:(19 × 8) + 7] × 8)

引索數值i用於從MAC當中選中31位元數,起始點為i + 1

extract31(MAC, i) = MAC[i + 1:i + (4 × 8) − 1]

注意,取得的31位元數長度僅有單位值的4位元組,可以容納於4位元組短語意味着沒有標記位。這是出於避免負數的模數運算,但是這也有許多不同的定義與實現。[2]

金鑰[編輯]

已有許多供應商(參考下面的列舉)提供軟件以及硬件金鑰。實現開放驗證提案的HOTP硬件金鑰實現往往比使用專有演算法的同類產品便宜許多。[3] 截止至2010年,這些硬件金鑰的價格已經很低。[4] 有些產品也可以同時用於生成強密碼。[5]

軟件金鑰在(幾乎)所有主要流動平台或智能電話均有提供(如J2ME,[6] Android,[7][8] iPhone,[9] BlackBerry,[10] Maemo,[11] macOS,[12] 以及Windows Mobile[10])。

接納程度[編輯]

儘管許多電腦媒體在2004-05年持負面態度,[13][14][15]自從IETF在2005年十二月將HOTP接納為RFC 4226標準之後,許多提供商開始生產相容HOTP的金鑰,甚至是基於此的整套驗證解決方案。

2010年伯頓集團英語Burton Group高德納諮詢公司的下轄部門)發表文章,表示「高德納諮詢公司預期基於硬件的一次性密碼封裝的市場會有一定程度的增長,對於智能電話來說,一次性密碼將會成為預設硬件平台的一部分」。[3]

另請參閱[編輯]

參考資料[編輯]

  1. ^ RFC 4226 - HOTP: An HMAC-Based One-Time Password Algorithm. IETF. 2005-12 [2019-03-18]. (原始內容存檔於2019-04-06) (英語). 
  2. ^ Frank, Hoornaert. HOTP: An HMAC-Based One-Time Password Algorithm. tools.ietf.org. [2019-03-18]. (原始內容存檔於2019-04-06). 
  3. ^ 3.0 3.1 Diodati, Mark. Road Map: Replacing Passwords with OTP Authentication. Burton Group. 2010 [2019-03-18]. (原始內容存檔於2011-07-21). Gartner's expectation is that the hardware OTP form factor will continue to enjoy modest growth while smartphone OTPs will grow and become the default hardware platform over time. ... If the organization does not need the extensive platform support, then OATH-based technology is likely a more cost-effective choice. 
  4. ^ Security Authentication Tokens - Entrust. Entrust. 2011 [2019-03-18]. (原始內容存檔於2013-04-05). Priced at $5 per token, the Entrust IdentityGuard Mini Token demonstrates that secure, reliable hardware authentication can be had at an attractive price. ... OATH and DES/3DES algorithm support 
  5. ^ Password sCrib Tokens - Smart Crib. Smart Crib. 2013 [2019-03-18]. (原始內容存檔於2013-09-04). You can get a token typing 4 updatable passwords and 8 digit OATH HOTP codes for the price of £35, no strings attached. 
  6. ^ DS3 Launches OathToken Midlet Application. Data Security Systems Solutions. 2006-02-24 [2019-03-18]. (原始內容存檔於2013-12-29). Singapore, Friday, 24 February 2006 - Data Security Systems Solutions is pleased to announce the launch of OathToken Midlet application, an extension of DS3 flagship product - Authentication Server. 
  7. ^ Android Token. diamondz... AT googlemail.com (not a full address, no better info on author could be found). 2009 [2019-03-18]. (原始內容存檔於2011-10-16). Android Token is a project to create OATH software tokens for the Android platform. Turning a mobile phone into a One Time Password (OTP) generation device which can be used in the place of hardware tokens. ... The project supports both HOTP (Event Tokens) and TOTP (Time Tokens) specifications. ... Code license: GNU GPL v3 
  8. ^ StrongAuth. StrongAuth. 2010 [2019-03-18]. (原始內容存檔於2010-05-18). Time-based one-time passcode generator based on HOTP (RFC 4226). 
  9. ^ Cobbs, Archie L. OATH Token. Archie L. Cobbs. 2010 [2019-03-18]. (原始內容存檔於2011-08-22). OATH Token is a free and open-source software token for two-factor authentication on the iPhone. OATH Token implements the RFC 4226 HOTP/OATH algorithm standard and is not tied to any proprietary server software. 
  10. ^ 10.0 10.1 ActivIdentity Soft Tokens. ActivIdentity. 2010 [2019-03-18]. (原始內容存檔於2010-09-17). All ActivIdentity Soft Tokens support the Initiative For Open Authentication (OATH) HMAC-Based One-Time Password (HOTP) algorithm. ... ActivIdentity Mobile Soft Tokens are available on leading handset operating systems, including BlackBerry®, Apple® iPhone®, Windows Mobile, and many other Java 2 Platform, Micro Edition (J2ME) enabled devices. 
  11. ^ Whitbeck, Sean. OTP Generator for N900. Sean Whitbeck. 2011 [2019-03-18]. (原始內容存檔於2020-08-23). OTP Generator for Maemo on the Nokia N900. Supports OATH tokens (HOTP,TOTP) as well as the Mobile-OTP algorithm. 
  12. ^ SecuriToken. Feel Good Software. 2011 [2019-03-18]. (原始內容存檔於2012-04-25). SecuriToken is an RFC compliant application to create and manage multiple software tokens for the OS X platform. Turning your Mac into a One Time Password (OTP) generation device which can be used in the place of hardware tokens. 
  13. ^ Kearns, Dave. Digging deeper into OATH doesn't look so good. Network World. 2004-12-06 [2019-03-18]. (原始內容存檔於2012-10-14). It may be that OATH will amount to something someday, but so far, it appears to be a stalking horse for VeriSign and that's not a bandwagon we should thoughtlessly jump on. 
  14. ^ Willoughby, Mark. No agreement on Oath authentication. Computerworld. 2005-03-21 [2019-03-18]. (原始內容存檔於2012-10-11). 
  15. ^ Kaliski, Burt. Algorithm agility and OATH. Computerworld. 2005-05-19 [2019-03-18]. (原始內容存檔於2012-10-11). Nevertheless, there is still good reason to question whether HOTP is suitable as a standard algorithm for OTP generation, and, more generally, whether such a standard algorithm is even necessary at all. 

外部連結[編輯]