CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/spec/lib/rex/proto/kerberos/model/checksum_spec.rb
Views: 11791
1
# -*- coding:binary -*-
2
require 'spec_helper'
3
4
5
RSpec.describe Rex::Proto::Kerberos::Model::Checksum do
6
7
subject(:checksum) do
8
described_class.new
9
end
10
11
let(:sample) do
12
"\x30\x19\xa0\x03\x02\x01\x07\xa1\x12\x04\x10\x9e\xf0\x84\xd6\x81" +
13
"\xe5\x16\x02\x32\xb1\xc3\x4e\xad\x83\x1d\x43"
14
end
15
16
let(:rsa_md5) { Rex::Proto::Kerberos::Crypto::Checksum::RSA_MD5 }
17
18
describe "#encode" do
19
it "encodes Rex::Proto::Kerberos::Model::Checksum correctly" do
20
checksum.type = rsa_md5
21
checksum.checksum = "\x9e\xf0\x84\xd6\x81\xe5\x16\x02\x32\xb1\xc3\x4e\xad\x83\x1d\x43"
22
expect(checksum.encode).to eq(sample)
23
end
24
end
25
26
describe "#decode" do
27
it "decodes Rex::Proto::Kerberos::Model::Checksum correctly" do
28
encoded_checksum = "\x30\x1a\xa0\x04\x02\x02\xff\x76\xa1\x12\x04\x10\xea\x62\x48\xe2\x8c\xe0\x76\x47\x06\xc7\x39\x99\x06\x35\x96\x89"
29
expected_type = Rex::Proto::Kerberos::Crypto::Checksum::HMAC_MD5
30
expected_checksum = "\xea\x62\x48\xe2\x8c\xe0\x76\x47\x06\xc7\x39\x99\x06\x35\x96\x89"
31
checksum.decode(encoded_checksum)
32
expect(checksum.type).to eq(expected_type)
33
expect(checksum.checksum).to eq(expected_checksum)
34
end
35
end
36
end
37
38