pbkdf_test.go 674 B

12345678910111213141516171819202122
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package pkcs12
  5. import (
  6. "bytes"
  7. "testing"
  8. )
  9. func TestThatPBKDFWorksCorrectlyForLongKeys(t *testing.T) {
  10. cipherInfo := shaWithTripleDESCBC{}
  11. salt := []byte("\xff\xff\xff\xff\xff\xff\xff\xff")
  12. password, _ := bmpString("sesame")
  13. key := cipherInfo.deriveKey(salt, password, 2048)
  14. if expected := []byte("\x7c\xd9\xfd\x3e\x2b\x3b\xe7\x69\x1a\x44\xe3\xbe\xf0\xf9\xea\x0f\xb9\xb8\x97\xd4\xe3\x25\xd9\xd1"); bytes.Compare(key, expected) != 0 {
  15. t.Fatalf("expected key '%x', but found '%x'", key, expected)
  16. }
  17. }