コード例 #1
0
ファイル: users.go プロジェクト: johnnymo87/EduChatSpike
func CreateStubUserWithSalt(name, password string, salt []byte) *models.User {
	StubUser = models.User{
		Name: name,
		Pass: auth.Pass{
			Salt: salt,
			Key:  auth.Hi([]byte(password), salt, auth.PASSWORD_ITERATIONS),
		},
	}
	return &StubUser
}
コード例 #2
0
			Expect(err).NotTo(BeNil())
		})

		It("should not accept invalid Client Proofs", func() {
			_, err := FinalResponseSCRAMSHA1([]byte("c=,r=abc,p=hello"), []byte("n=,r=,r=abc,s=,i="))
			Expect(err).NotTo(BeNil())
		})
	})

	Context("full handshake", func() {

		salt, _ := auth.DecodeBase64([]byte("QSXCR+Q6sek8bf92"))
		StubUser = models.User{
			Pass: auth.Pass{
				Salt: salt,
				Key:  auth.Hi([]byte("pencil"), salt, auth.PASSWORD_ITERATIONS),
			},
		}
		iters := strconv.Itoa(auth.PASSWORD_ITERATIONS)
		clientNonce := "fyko+d2lbbFgONRv9qkxdawL"
		nonce := "3rfcNHYJY1ZVvWVs7j"
		username := "******"

		It("should respond correctly to the first message", func() {
			clientMsg := "n,,u=" + username + ",n=" + clientNonce
			msg, err := InitialResponseSCRAMSHA1([]byte(clientMsg), []byte(nonce))

			Expect(err).To(BeNil())
			Expect(string(msg)).To(Equal("r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,s=QSXCR+Q6sek8bf92,i=" + iters))
		})