Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPB-6162 update x 509 verification with new client identity format #3811

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libs/wire-api/src/Wire/API/MLS/Credential.hs
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ instance ParseMLS ClientIdentity where
either fail pure . (mkDomain . T.pack) =<< many' anyChar
pure $ ClientIdentity dom uid cid

-- format of the x509 client identity: {userid}!{deviceid}@{host}
-- format of the x509 client identity: {userid}%21{deviceid}@{host}
parseX509ClientIdentity :: Get ClientIdentity
parseX509ClientIdentity = do
b64uuid <- getByteString 22
uidBytes <- either fail pure $ B64URL.decodeUnpadded b64uuid
uid <- maybe (fail "Invalid UUID") (pure . Id) $ fromByteString (L.fromStrict uidBytes)
char '!'
string "%21"
cid <- ClientId <$> hexadecimal
char '@'
dom <-
Expand Down
1 change: 1 addition & 0 deletions libs/wire-api/src/Wire/API/MLS/KeyPackage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module Wire.API.MLS.KeyPackage
kpRef',
KeyPackageTBS (..),
KeyPackageRef (..),
sanIdentity,
)
where

Expand Down
9 changes: 8 additions & 1 deletion libs/wire-api/test/unit/Test/Wire/API/MLS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,16 @@ tests =
testCase "parse application message" testParseApplication,
testCase "parse welcome and groupinfo message" testParseWelcomeAndGroupInfo,
testCase "key package ref" testKeyPackageRef,
testCase "create signed remove proposal" testRemoveProposalMessageSignature
testCase "create signed remove proposal" testRemoveProposalMessageSignature,
testCase "parse client identity" testParseClientIdentity
]

testParseClientIdentity :: IO ()
testParseClientIdentity = do
let cid = "wireapp://qHiDLsbkT2-p9uSJsmrZ_A%217f39900830740008@wire.com"
let actual = sanIdentity cid
show <$> actual @?= Right "a878832e-c6e4-4f6f-a9f6-e489b26ad9fc:7f39900830740008@wire.com"

testParseKeyPackage :: IO ()
testParseKeyPackage = do
alice <- randomIdentity
Expand Down
Loading