DSInternals/Src/DSInternals.Common.Test/SupplementalCredentialsTest...

149 lines
43 KiB
C#
Raw Normal View History

2015-12-26 22:44:43 +00:00
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DSInternals.Common.Data;
using DSInternals.Common.Cryptography;
2015-12-26 22:44:43 +00:00
namespace DSInternals.Common.Test
{
[TestClass]
public class SupplementalCredentialsTester
{
[TestMethod]
public void SupplementalCredentials_Parse_ADAM()
{
// AD LDS / ADAM has a slightly different structure of supplemental credentials
byte[] input = "0100000001000000e80100000600000001000000e00100003100011d000000000000000000000000af4156909297baece4e553b731d9d552da58c12e5880cad54a3f909c07b0792eec9d262783c811ad9cc7aeb1ab019fe0af4156909297baece4e553b731d9d552af4156909297baece4e553b731d9d552ec9d262783c811ad9cc7aeb1ab019fe0da58c12e5880cad54a3f909c07b0792e95e11e920c7405ca6639d932888cc11c53d9e953141b322f29eb1a02798c299042eea90067734b2a81abbc79618cc1519d9aac28e63107a495266e755f7a2babac6b5dfb3bfa3b7039058310d5b36ccc7c97824dd59b9a6a053b5fae3d8603f20a5e2bc3111c759efb3a91e3740633e83b12daad09e83cb92477ac59993c5a843b12daad09e83cb92477ac59993c5a843b12daad09e83cb92477ac59993c5a8471e7228faba51df979beef06b34f791820aa1475f40540f0db59f9d2d93fc3da5f88f6d82d185741a82c7fa79e801c6d8eae592a0ce55271a17de0b39cf1e5e9923354fb99887724cf2b10e88108776b427804b8a6d6ed92c11ecb94e40da72c0c997bc1906b1f0092d61bd0efee428b0c997bc1906b1f0092d61bd0efee428b0c997bc1906b1f0092d61bd0efee428bd93e9a9a7452dff036a67a5d5d333d7c4effe21b0afc142382943ef26024649aaa6a6a95c237f2b8efa2f13ecb0cb220".HexToBinary();
var result = new SupplementalCredentials(input);
}
2015-12-26 22:44:43 +00:00
[TestMethod]
public void SupplementalCredentials_Parse_Null()
2015-12-26 22:44:43 +00:00
{
byte[] input = null;
var result = new SupplementalCredentials(input);
}
2015-12-26 22:44:43 +00:00
[TestMethod]
public void SupplementalCredentials_Parse_Empty1()
2015-12-26 22:44:43 +00:00
{
// Test 13B empty structure
2015-12-26 22:44:43 +00:00
byte[] input = "00000000000000000000000000".HexToBinary();
var result = new SupplementalCredentials(input);
}
[TestMethod]
public void SupplementalCredentials_Parse_Empty2()
{
// Test 111B empty structure
byte[] emptyCredentials = "000000006200000000000000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000500000".HexToBinary();
var result = new SupplementalCredentials(emptyCredentials);
}
[TestMethod]
public void SupplementalCredentials_Create_Empty()
{
var result = new SupplementalCredentials();
string emptyCredentials = "000000006200000000000000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000500000";
Assert.AreEqual(emptyCredentials, result.ToByteArray().ToHex());
}
2015-12-26 22:44:43 +00:00
[TestMethod]
public void SupplementalCredentials_Parse_W2k16_Vector1()
2015-12-26 22:44:43 +00:00
{
byte[] blob = "00000000780a000000000000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000500005003200200001005000720069006d006100720079003a004e0054004c004d002d005300740072006f006e0067002d004e0054004f005700460039303534356562346361653431363336386630313965353965373765383535313600980301005000720069006d006100720079003a004b00650072006200650072006f0073002d004e0065007700650072002d004b0065007900730030343030303030303033303030303030303330303033303031633030316330303038303130303030303031303030303030303030303030303030303030303030303031303030303031323030303030303230303030303030323430313030303030303030303030303030303030303030303031303030303031313030303030303130303030303030343430313030303030303030303030303030303030303030303031303030303030333030303030303038303030303030353430313030303030303030303030303030303030303030303031303030303031323030303030303230303030303030356330313030303030303030303030303030303030303030303031303030303031313030303030303130303030303030376330313030303030303030303030303030303030303030303031303030303030333030303030303038303030303030386330313030303030303030303030303030303030303030303031303030303031323030303030303230303030303030393430313030303030303030303030303030303030303030303031303030303031313030303030303130303030303030623430313030303030303030303030303030303030303030303031303030303030333030303030303038303030303030633430313030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303034313030343430303431303035343030353530303464303032653030343330303466303034643030373430303635303037333030373430303066346562363736313034616431666361633961386662396632613139643634373763353263613538346234626536383934383531643436396266313034396361343737626238323665393864383634363566663439313562383539633663643435333832306461383362366436346130663465623637363130346164316663616339613866623966326131396436343737633532636135383462346265363839343835316434363962663130343963613437376262383236653938643836343635666634393135623835396336636434353338323064613833623664363461306634656236373631303461643166636163396138666239663261313964363437376335326361353834623462653638393438353164343639626631303439636134373762623832366539386438363436356666343931356238353963366364343533383230646138336236643634612000f00001005000720069006d006100720079003a004b00650072006200650072006f0073003033303030303030303130303031303031633030316330303463303030303030303030303030303030303030303030303033303030303030303830303030303036383030303030303030303030303030303030303030303030333030303030303038303030303030373030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030343130303434303034313030353430303535303034643030326530303433303034663030346430303734303036353030373330303734303034353338323064613833623664363461343533383230646138336236643634611000d80002005000610063006b0061006700650073003465303035343030346330303464303032643030353330303734303037323030366630303665303036373030326430303465303035343030346630303537303034363030303030303462303036353030373230303632303036353030373230303666303037333030326430303465303036353030373730303635303037323030326430303462303036353030373930303733303030303030346230303635303037323030363230303635303037323030366630303733303030303030353730303434303036393030363730303635303037333030373430301e00c00301005000720069006d006100720079003a0057004400690067006500730074003331303030313164303030303030303030303030303030303030303030303030333837323365643334643664663834666238383937326365303062396432383935326539353462316639323336386434306662383863396235346466326435616532373561656562653664306130646137623035373266373139626233303762333837323365643334643664663834666238383937326365303062396432383935326539353462316639323336386434306662383863396235346466326435616665393363366363363130323862646439336237343034326564373738633233333837323365643334643664663834666238383937326365303062396432383934323930373262666661356265303735393863613433616535323833333733323432393037326266666135626530
var credentials = new SupplementalCredentials(blob);
byte[] blob2 = credentials.ToByteArray();
Assert.AreEqual(blob.Length, blob2.Length);
Assert.AreEqual(blob.ToHex(), blob2.ToHex());
}
[TestMethod]
public void SupplementalCredentials_Parse_W2k16_Vector2()
{
byte[] blob = "000000005008000000000000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000500005003200200001005000720069006d006100720079003a004e0054004c004d002d005300740072006f006e0067002d004e0054004f005700460031643638373531326339333534646365653233376665613930643139356363373600a00101005000720069006d006100720079003a004b00650072006200650072006f0073002d004e0065007700650072002d004b0065007900730030343030303030303033303030303030303030303030303032303030323030303738303030303030303031303030303030303030303030303030303030303030303031303030303031323030303030303230303030303030393830303030303030303030303030303030303030303030303031303030303031313030303030303130303030303030623830303030303030303030303030303030303030303030303031303030303030333030303030303038303030303030633830303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303034313030343430303431303035343030353530303464303032653030343330303466303034643030373530303733303036353030373230303330303033323030363232666361316431326465316466363565383430616664356633623938343462313861373261383261656436653365353863333932353737353366646661383330363636393734636237323965663662643434663865616233323936653563313366386664333764353537613430312000c00001005000720069006d006100720079003a004b00650072006200650072006f0073003033303030303030303130303030303032303030323030303338303030303030303030303030303030303030303030303033303030303030303830303030303035383030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303034313030343430303431303035343030353530303464303032653030343330303466303034643030373530303733303036353030373230303330303033323030313366386664333764353537613430311000d80002005000610063006b0061006700650073003465303035343030346330303464303032643030353330303734303037323030366630303665303036373030326430303465303035343030346630303537303034363030303030303462303036353030373230303632303036353030373230303666303037333030326430303465303036353030373730303635303037323030326430303462303036353030373930303733303030303030346230303635303037323030363230303635303037323030366630303733303030303030353730303434303036393030363730303635303037333030373430301e00c00301005000720069006d006100720079003a0057004400690067006500730074003331303030313164303030303030303030303030303030303030303030303030396333383665666438313466373439636565306632613965366564376563363332643834353539396334626662353333373230373062336266613264633932323563306335383933343035653635313833343232313266386439356436383764396333383665666438313466373439636565306632613965366564376563363332643834353539396334626662353333373230373062336266613264633932323835303739313132333432653236343330316263656664323237653666316666396333383665666438313466373439636565306632613965366564376563363332333838306436613431616133616333373031356538326265306662303336306363363438343935323264373531323930326465323631323030343130323062393466623464633364623038613366393534373136643664326436656336306263333339303665313962303432326337663836646336386632653635616532386363363438343935323264373531323930326465323631323030343130323062353666303033626234353261663366663464316337346436346464303536313963333339303665313962303432326337663836646336386632653635616532386166643734646336663337613237373266303839636463616632643666396162636633313936613638313731343936306636646339323764613736386466626332323738633665653364306433643861326134363533666630656239663062303933396266643265633862313165626238653132656363636361376635613139353861393461346332613463326234383937323031383134623562623866623036376366333533666563623234333535646635353865383762653435343238626133663434623361303734633466636463626162393465363530353336316637613366343462336130373463346663646362616239346536353035333631663739326563366564623533623836613932663436396532633933643335613561643063333131396663653638613365333135313432313136373936653139663835346233393861613932653666363333316335363063366263393933326438643636316331613665393037393730643431366235353862
var credentials = new SupplementalCredentials(blob);
byte[] blob2 = credentials.ToByteArray();
Assert.AreEqual(blob.Length, blob2.Length);
Assert.AreEqual(blob.ToHex(), blob2.ToHex());
}
[TestMethod]
public void SupplementalCredentials_Parse_W2k16_Vector3()
{
byte[] blob = "000000008809000000000000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000500005003200200001005000720069006d006100720079003a004e0054004c004d002d005300740072006f006e0067002d004e0054004f005700460064626533343361626337656632643162313166366136643537666437393636383600a00201005000720069006d006100720079003a004b00650072006200650072006f0073002d004e0065007700650072002d004b006500790073003034303030303030303330303030303030333030303030303230303032303030633030303030303030303130303030303030303030303030303030303030303030303130303030303132303030303030323030303030303065303030303030303030303030303030303030303030303030303130303030303131303030303030313030303030303030303031303030303030303030303030303030303030303030303130303030303033303030303030303830303030303031303031303030303030303030303030303030303030303030303130303030303132303030303030323030303030303031383031303030303030303030303030303030303030303030303130303030303131303030303030313030303030303033383031303030303030303030303030303030303030303030303130303030303033303030303030303830303030303034383031303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303431303034343030343130303534303035353030346430303265303034333030346630303464303037353030373330303635303037323030333030303333303037646266326238323237313934353066633533303531343334626438336361616433613436323462326166316538396461633266353665336438316436663937633362653262636439616533336665643862383338383463643032386532353936326539363765363062643637356561376462663262383232373139343530666335333035313433346264383363616164336134363234623261663165383964616332663536653364383164366639376333626532626364396165333366656438623833383834636430323865323539363265393637653630626436373565612000f80001005000720069006d006100720079003a004b00650072006200650072006f00730030333030303030303031303030313030323030303230303034633030303030303030303030303030303030303030303030333030303030303038303030303030366330303030303030303030303030303030303030303030303330303030303030383030303030303734303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303431303034343030343130303534303035353030346430303265303034333030346630303464303037353030373330303635303037323030333030303333303036326539363765363062643637356561363265393637653630626436373565611000d80002005000610063006b0061006700650073003465303035343030346330303464303032643030353330303734303037323030366630303665303036373030326430303465303035343030346630303537303034363030303030303462303036353030373230303632303036353030373230303666303037333030326430303465303036353030373730303635303037323030326430303462303036353030373930303733303030303030346230303635303037323030363230303635303037323030366630303733303030303030353730303434303036393030363730303635303037333030373430301e00c00301005000720069006d006100720079003a0057004400690067006500730074003331303030313164303030303030303030303030303030303030303030303030303366633031646537313162303333313538613036303834303734353839303437343136346632326565316630343532613637373962343239303161383530616334343739353331346634373836363931336236646466323038623663396632303366633031646537313162303333313538613036303834303734353839303437343136346632326565316630343532613637373962343239303161383530613635316538363031353331396162616336626239343032653166373432316632303366633031646537313162303333313538613036303834303734353839303438386336356333663565323233646136666238663866346532616330346366323965336361396635346365656632343162373330373733356636636365643033633539636561333635346465646465346636346335623637366230666563616530303561343731393135313636656333306538386262383732383335373362663965336361396635346365656632343162373330373733356636636365643033373261356132346132623465333761656261633432363933623330323732633130303561343731393135313636656333306538386262383732383335373362663132313733623336393266333734623330343230626264663234623435653963363130326339656165633433393239653637303131336532353231656566
var credentials = new SupplementalCredentials(blob);
byte[] blob2 = credentials.ToByteArray();
Assert.AreEqual(blob.Length, blob2.Length);
Assert.AreEqual(blob.ToHex(), blob2.ToHex());
}
[TestMethod]
public void SupplementalCredentials_Parse_W2k16_Vector4()
{
byte[] blob = "00000000880a000000000000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000500005003200200001005000720069006d006100720079003a004e0054004c004d002d005300740072006f006e0067002d004e0054004f005700460064613664376662373363666261323738336233323836333563303130613163343600a00301005000720069006d006100720079003a004b00650072006200650072006f0073002d004e0065007700650072002d004b00650079007300303430303030303030333030303030303033303030333030323030303230303030383031303030303030313030303030303030303030303030303030303030303030313030303030313230303030303032303030303030303238303130303030303030303030303030303030303030303030313030303030313130303030303031303030303030303438303130303030303030303030303030303030303030303030313030303030303330303030303030383030303030303538303130303030303030303030303030303030303030303030313030303030313230303030303032303030303030303630303130303030303030303030303030303030303030303030313030303030313130303030303031303030303030303830303130303030303030303030303030303030303030303030313030303030303330303030303030383030303030303930303130303030303030303030303030303030303030303030313030303030313230303030303032303030303030303938303130303030303030303030303030303030303030303030313030303030313130303030303031303030303030306238303130303030303030303030303030303030303030303030313030303030303330303030303030383030303030306338303130303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030343130303434303034313030353430303535303034643030326530303433303034663030346430303735303037333030363530303732303033303030333430306232326636303466343463666332653263613432316636656333613931646433616637333031396233303134383564343662373566316163303266626433353665383031333136306330333862613566363762363966663739363365316162306338366233313362626338396235663164656438353334393062316664653339343036623733623631356130633065616432343430316436326237396639623737643162656530633330666639373564313465306238383235613032643239343163336330653661353536306639373430313733306564393037363435313565623232663630346634346366633265326361343231663665633361393164643361663733303139623330313438356434366237356631616330326662643335366538303133313630633033386261356636376236396666373936336531616230633836623331336262633839623566312000f80001005000720069006d006100720079003a004b00650072006200650072006f00730030333030303030303031303030313030323030303230303034633030303030303030303030303030303030303030303030333030303030303038303030303030366330303030303030303030303030303030303030303030303330303030303030383030303030303734303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303431303034343030343130303534303035353030346430303265303034333030346630303464303037353030373330303635303037323030333030303334303063383662333133626263383962356631303137333065643930373634353135651000d80002005000610063006b0061006700650073003465303035343030346330303464303032643030353330303734303037323030366630303665303036373030326430303465303035343030346630303537303034363030303030303462303036353030373230303632303036353030373230303666303037333030326430303465303036353030373730303635303037323030326430303462303036353030373930303733303030303030346230303635303037323030363230303635303037323030366630303733303030303030353730303434303036393030363730303635303037333030373430301e00c00301005000720069006d006100720079003a00570044006900670065007300740033313030303131643030303030303030303030303030303030303030303030303637333137633437393534346464323762313137383463373161353531306264626336343935313933323233646330326533353762303965363961636438626638366630356134613564663462616165303161623931663562663131653561613637333137633437393534346464323762313137383463373161353531306264626336343935313933323233646330326533353762303965363961636438626632323661313034643065666663643035333032613965626235383263633565643637333137633437393534346464323762313137383463373161353531306264643031633237633061643761626437663765616161356265303165303463
var credentials = new SupplementalCredentials(blob);
byte[] blob2 = credentials.ToByteArray();
Assert.AreEqual(blob.Length, blob2.Length);
Assert.AreEqual(blob.ToHex(), blob2.ToHex());
}
[TestMethod]
public void SupplementalCredentials_Parse_W2k16_Vector5()
{
byte[] blob = "00000000b00a000000000000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000500004003600e00301005000720069006d006100720079003a004b00650072006200650072006f0073002d004e0065007700650072002d004b0065007900730030343030303030303033303030303030303330303033303034303030343030303038303130303030303031303030303030303030303030303030303030303030303031303030303031323030303030303230303030303030343830313030303030303030303030303030303030303030303031303030303031313030303030303130303030303030363830313030303030303030303030303030303030303030303031303030303030333030303030303038303030303030373830313030303030303030303030303030303030303030303031303030303031323030303030303230303030303030383030313030303030303030303030303030303030303030303031303030303031313030303030303130303030303030613030313030303030303030303030303030303030303030303031303030303030333030303030303038303030303030623030313030303030303030303030303030303030303030303031303030303031323030303030303230303030303030623830313030303030303030303030303030303030303030303031303030303031313030303030303130303030303030643830313030303030303030303030303030303030303030303031303030303030333030303030303038303030303030653830313030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303034313030343430303431303035343030353530303464303032653030343330303466303034643030363830303666303037333030373430303663303036663030366530303264303036343030363330303331303032653030363130303634303036313030373430303735303036643030326530303633303036663030366430303833643563663533353265393033356565366539666266373832663630626333393866353233643263306130646538616438366262613733313932643664353130303435663633353064393462616462383332666436333162336633663938633730393163653835343536313364333165396163646531313539323530316561333839643564646161353832656133363562356238366133363163336235333239333632323330656266366464303065393836653333663338356538363661636334333663623938633132363930306461346364353765613062336434303461613335363436643936316261386539346535326165303266366631383135613530663961613061346261656337623138356166386665623333383834636533333938636635633866376430653637613366643466393730333861373431383465646131306137326166383763316630312000380101005000720069006d006100720079003a004b00650072006200650072006f0073003033303030303030303130303031303034303030343030303463303030303030303030303030303030303030303030303033303030303030303830303030303038633030303030303030303030303030303030303030303030333030303030303038303030303030393430303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030343130303434303034313030353430303535303034643030326530303433303034663030346430303638303036663030373330303734303036633030366630303665303032643030363430303633303033313030326530303631303036343030363130303734303037353030366430303265303036333030366630303664303037303931636538353435363133643331613463643537656130623364343034611000d80002005000610063006b0061006700650073003465303035343030346330303464303032643030353330303734303037323030366630303665303036373030326430303465303035343030346630303537303034363030303030303462303036353030373230303632303036353030373230303666303037333030326430303465303036353030373730303635303037323030326430303462303036353030373930303733303030303030346230303635303037323030363230303635303037323030366630303733303030303030353730303434303036393030363730303635303037333030373430301e00c00301005000720069006d006100720079003a005700440069006700650073007400333130303031316430303030303030303030303030303030303030303030303064383634373932366530656538323538326262626131323962386562376131663234343839646137656464393137353438383437343739303437666236663138643836343739323665306565383235383262626261313239623865623761316664383634373932366530656538323538326262626131323962386562376131666565353838336331333061313039303530326330303634363564653236636163656535383833633133306131303930353032633030363436356465323663616333333335303933343338393030643862383033656430
var credentials = new SupplementalCredentials(blob);
byte[] blob2 = credentials.ToByteArray();
// Note that we do not test the serialized value for equality, because unlike Windows Server 2016, our implementation does not put the NTLM-Strong-NTOWF property name to the Properties list if this package is not actually present.
}
[TestMethod]
public void SupplementalCredentials_Parse_W2k3_Vector1()
{
byte[] blob = "000000000406000000000000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000500003002000400101005000720069006d006100720079003a004b00650072006200650072006f00730030333030303030303032303030303030333030303330303035303030303030303030303030303030303030303030303030333030303030303038303030303030383030303030303030303030303030303030303030303030303130303030303030383030303030303838303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030343330303466303034653030353430303466303035333030346630303265303034333030346630303464303034313030363430303664303036393030366530303639303037333030373430303732303036313030373430303666303037323030616564303263353232303463613263656165643032633532323034636132636530303030303030303030303030303030303030303030303030303030303030301000400002005000610063006b006100670065007300346230303635303037323030363230303635303037323030366630303733303030303030353730303434303036393030363730303635303037333030373430301e00c00301005000720069006d006100720079003a00570044006900670065007300740033313030303131643030303030303030303030303030303030303030303030303431313563366234376637373561306136663034353830666531323634346635643336363162336461396134366665303931316335303261636231636465363463643834393763316532626331636461656664343662613162326663613439313431313563366234376637373561306136663034353830666531323634346635656134383731323434626665316536396538326432636562363666326132313664343338643964306161626666343830306531313434316166633530303437336137623662373932336139323630333530303538623335656263356537656138343135356530343563623837373038656539663130613261363539626363363566303136313039343636336264653235343333666430653162643637653862626562356662386265336430363435653330366362353865663162323062373537396136303435346463663837376562633635393031623661393338633536633934313535653034356362383737303865653966313061326136353962636336356162633162323261306565363361383233303632653666623966393639333661353061323736383435356331666662386231333863613064663633636635326136343338343863333661333262386162383736656462333334303638663239636134306338656337356230373038303866313234336263616165653364356462393139333838616238326132373936626633306331356466373632343435666439666331343861623839313163663434393663653137393331303432366336663232396139613166353438393530396633383962613865643739353330626339653464386230303037346466366133366465313830643163396138643863633638623863346633333964333733366564653263346330626334653533663366663230396165336231646336373839663930663335326532666632373331313162396232326461653234356238326333653535303631323635623238383630376332366236646638373236333034366132313363363534396439383233383363663938656437386465303531353164636533393538666539643435393638313032343062306434303562383737336566323465323964343638356564383261353164353832633136366432656639616232623233616262383730383062383535646632663532636132383461356637663262323238623464333035386466303832373234396433366566316636386163393363643331373330336336393866663800".HexToBinary();
var credentials = new SupplementalCredentials(blob);
byte[] blob2 = credentials.ToByteArray();
// Note that we do not test the serialized value for equality, because Windows Server 2003 uses different credential paddings.
}
[TestMethod]
public void SupplementalCredentials_Parse_W2k3_Vector2()
{
byte[] blob = "00000000a806000000000000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000500003002000e40101005000720069006d006100720079003a004b00650072006200650072006f007300303330303030303030323030303230303461303034613030373830303030303030303030303030303030303030303030303330303030303030383030303030306332303030303030303030303030303030303030303030303031303030303030303830303030303063613030303030303030303030303030303030303030303030333030303030303038303030303030643230303030303030303030303030303030303030303030303130303030303030383030303030306461303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030343330303466303034653030353430303466303035333030346630303265303034333030346630303464303036383030366630303733303037343030373730303639303036653030333230303662303033333030373230303332303036353030363530303265303036333030366630303665303037343030366630303733303036663030326530303633303036663030366430306439623333656230363465333835646664396233336562303634653338356466663139316539613762353631353235646631393165396137623536313532356430303030303030303030303030303030303030303030303030303030303030301000400002005000610063006b006100670065007300346230303635303037323030363230303635303037323030366630303733303030303030353730303434303036393030363730303635303037333030373430301e00c00301005000720069006d006100720079003a00570044006900670065007300740033313030303131643030303030303030303030303030303030303030303030303962643638616265363465383266666264376639393666343736633161613663363565623965326331386363363961306233633031326136353763323264623739626436386162653634653832666662643766393936663437366331616136633962643638616265363465383266666264376639393666343736633161613663626133343231303165303331653165653630366439633436313535366538623662613334323130316530333165316565363036643963343631353536653862366237336338396333346532643661643162353335333362393733383538653165633133373331393034373534393966616261633636343336656234643966343235633232633233393532643432643565393531396335303361326235303832386135333838393633656234386136663466386231623734393361323262366631613533383839363365623438613666346638623162373439336132326236663163313337333139303437353439396661626163363634333665623464396634326331333733313930343735343939666162616336363433366562346439663432313534313936313665323663383738623363666439356366653030306266666663363261333366336136613135356562363339393531356535363638623863653936643964336137373739383633393037386433306365623539633538376365306662626363633833643237373739336630633331313637353366306535653534376234663561336638336666383439636433656661633863343761333637313335386234656239393732393434633235636432663631613565616133626631343762346635613366383366663834396364336566616338633437613336373161343632323165626135623463623930323731343933333831663934353935333334636261613034616238386634326562613536376135636134393837623936613436323231656261356234636239303237313439333338316639343539353333383432393939353465303561613636366233646665353138313164626466373762636536313366376264383437656465643232386335343137303664376633396533376339333533613133656563396666633439663665386634653639613563393932353633663566363631396665303537326234336532663066373934363630303363303631636634666437623836346461356535316165346365623465633939323536336635663636313966653035373262343365326630663739343672".HexToBinary();
var credentials = new SupplementalCredentials(blob);
byte[] blob2 = credentials.ToByteArray();
// Note that we do not test the serialized value for equality, because Windows Server 2003 uses different credential paddings.
}
[TestMethod]
public void SupplementalCredentials_Generate1()
{
var credentials = new SupplementalCredentials(@"Pa$$w0rd".ToSecureString(), "Administrator", "Administrator@Adatum.com", "ADATUM", "Adatum.com");
byte[] blob = credentials.ToByteArray();
var credentials2 = new SupplementalCredentials(blob);
// Test integrity
Assert.AreEqual(credentials2.ClearText, credentials.ClearText);
Assert.AreEqual(credentials2.NTLMStrongHash.Length, credentials.NTLMStrongHash.Length);
Assert.AreEqual(credentials2.WDigest.Length, credentials.WDigest.Length);
Assert.AreEqual(credentials2.Kerberos.ToByteArray().ToHex(), credentials.Kerberos.ToByteArray().ToHex());
Assert.AreEqual(credentials2.KerberosNew.ToByteArray().ToHex(), credentials.KerberosNew.ToByteArray().ToHex());
}
[TestMethod]
public void SupplementalCredentials_Generate2()
{
var credentials = new SupplementalCredentials(@"Pa$$w0rd".ToSecureString(), "user02", null, "ADATUM", "Adatum.com");
byte[] blob = credentials.ToByteArray();
byte[] expectedBlob = "000000005008000000000000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000500005003200200001005000720069006d006100720079003a004e0054004c004d002d005300740072006f006e0067002d004e0054004f005700460031643638373531326339333534646365653233376665613930643139356363373600a00101005000720069006d006100720079003a004b00650072006200650072006f0073002d004e0065007700650072002d004b0065007900730030343030303030303033303030303030303030303030303032303030323030303738303030303030303031303030303030303030303030303030303030303030303031303030303031323030303030303230303030303030393830303030303030303030303030303030303030303030303031303030303031313030303030303130303030303030623830303030303030303030303030303030303030303030303031303030303030333030303030303038303030303030633830303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303034313030343430303431303035343030353530303464303032653030343330303466303034643030373530303733303036353030373230303330303033323030363232666361316431326465316466363565383430616664356633623938343462313861373261383261656436653365353863333932353737353366646661383330363636393734636237323965663662643434663865616233323936653563313366386664333764353537613430312000c00001005000720069006d006100720079003a004b00650072006200650072006f0073003033303030303030303130303030303032303030323030303338303030303030303030303030303030303030303030303033303030303030303830303030303035383030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303034313030343430303431303035343030353530303464303032653030343330303466303034643030373530303733303036353030373230303330303033323030313366386664333764353537613430311000d80002005000610063006b0061006700650073003465303035343030346330303464303032643030353330303734303037323030366630303665303036373030326430303465303035343030346630303537303034363030303030303462303036353030373230303632303036353030373230303666303037333030326430303465303036353030373730303635303037323030326430303462303036353030373930303733303030303030346230303635303037323030363230303635303037323030366630303733303030303030353730303434303036393030363730303635303037333030373430301e00c00301005000720069006d006100720079003a00570044006900670065007300740033313030303131643030303030303030303030303030303030303030303030303963333836656664383134663734396365653066326139653665643765633633326438343535393963346266623533333732303730623362666132646339323235633063353839333430356536353138333432323132663864393564363837643963333836656664383134663734396365653066326139653665643765633633326438343535393963346266623533333732303730623362666132646339323238353037393131323334326532363433303162636566643232376536663166663963333836656664383134663734396365653066326139653665643765633633323338383064366134316161336163333730313565383262653066623033363063633634383439353232643735313239303264653236313230303431303230623934666234646333646230386133663935343731366436643264366563363062633333393036653139623034323263376638366463363866326536356165323863633634383439353232643735313239303264653236313230303431303230623536663030336262343532616633666634643163373464363464643035363139633333393036653139623034323263376638366463363866326536356165323861666437346463366633376132373732663038396364636166326436663961626366333139366136383137313439363066366463393237646137363864666263323237386336656533643064336438613261343635336666306562396630623039333962666432656338623131656262386531326563636363613766356131393538613934613463326134633262343839373230313831346235626238666230363763663335336665636232343335356466353538653837626534353432386261336634346233613037346334666364636261623934653635303533363166376133663434623361303734633466636463626162393465363530353336316637393265633665646235336238366139326634363965326339336433356135616430633331313966636536386133653331353134323131363739366531396638353462333938616139326536663633333163353630633662633939333264386436363163316136653930373937306434313662
var expectedCredentials = new SupplementalCredentials(expectedBlob);
// Test integrity
Assert.AreEqual(expectedCredentials.ClearText, credentials.ClearText);
Assert.AreEqual(expectedCredentials.NTLMStrongHash.Length, credentials.NTLMStrongHash.Length);
Assert.AreEqual(WDigestHash.Encode(expectedCredentials.WDigest).ToHex(), WDigestHash.Encode(credentials.WDigest).ToHex());
Assert.AreEqual(expectedCredentials.Kerberos.ToByteArray().ToHex(), credentials.Kerberos.ToByteArray().ToHex());
Assert.AreEqual(expectedCredentials.KerberosNew.ToByteArray().ToHex(), credentials.KerberosNew.ToByteArray().ToHex());
2015-12-26 22:44:43 +00:00
}
}
}