This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git


The following commit(s) were added to refs/heads/master by this push:
     new aa99c4c  sec: Fix infinite loop
aa99c4c is described below

commit aa99c4ccd95b2da7d2ccc916b287faf509146e99
Author: Christopher Collins <ccoll...@apache.org>
AuthorDate: Thu Aug 20 14:07:48 2020 -0700

    sec: Fix infinite loop
    
    If the caller of EncryptAES() supplied a nonce shorter than 16 bytes,
    the function would enter an endless loop.
---
 sec/encrypt.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sec/encrypt.go b/sec/encrypt.go
index 8d142e3..97aaaec 100644
--- a/sec/encrypt.go
+++ b/sec/encrypt.go
@@ -263,7 +263,7 @@ func EncryptAES(plain []byte, secret []byte, nonce []byte) 
([]byte, error) {
 
        iv := nonce
        for len(iv) < 16 {
-               iv = append(nonce, 0)
+               iv = append(iv, 0)
        }
 
        stream := cipher.NewCTR(blk, iv)

Reply via email to