Kaynağa Gözat

Use ZeroPadding in HMAC. Update README.

Marcin Krzyżanowski 9 yıl önce
ebeveyn
işleme
71dc6af7be
2 değiştirilmiş dosya ile 3 ekleme ve 4 silme
  1. 1 0
      README.md
  2. 2 4
      Sources/CryptoSwift/HMAC.swift

+ 1 - 0
README.md

@@ -56,6 +56,7 @@ Good mood
 
 #### Data padding
 - [PKCS#7](http://tools.ietf.org/html/rfc5652#section-6.3)
+- Zero padding
 - NoPadding
 
 ##Why

+ 2 - 4
Sources/CryptoSwift/HMAC.swift

@@ -63,10 +63,8 @@ final public class HMAC {
                 self.key = hash
             }
         }
-        
-        if (key.count < variant.blockSize()) { // keys shorter than blocksize are zero-padded
-            self.key = key + Array<UInt8>(repeating: 0, count: variant.blockSize() - key.count)
-        }
+
+        self.key = ZeroPadding().add(to: key, blockSize: variant.blockSize())
     }
 
     public func authenticate(bytes:Array<UInt8>) -> Array<UInt8>? {