OMA DM1.2 md5 digest calculation

1.1k views Asked by At

I am implementing a server for communication using the OMA DM 1.2 SyncML protocol and reffers to the OMA Device Management Security document. I am having issues with authentication. The client sends a challenge to the server as:

<Chal>
    <Meta>
        <Format xmlns="syncml:metinf">b64</Format>
        <Type xmlns="syncml:metinf">syncml:auth-md5</Type>
        <NextNonce xmlns="syncml:metinf">RLLe7tWM313qHMq9ooUZUPJX0RqU9mEZuyoVF+jXhqQ=</NextNonce>
    </Meta>
</Chal>

I then calculate the md5-digest to return to the device using the java code, where nonce is the Base64 string in "NextNonce" in challenge above:

MessageDigest digest = MessageDigest.getInstance("MD5");
String usrPwd = username + ":" + password;
String usrPwdHash = Base64.encodeBase64String(digest.digest(usrPwd.getBytes("utf-8")));
String usrPwdNonce = usrPwdHash + ":" + nonce;
String usrPwdNonceHash = Base64.encodeBase64String(digest.digest(usrPwdNonce.getBytes("utf-8")));
return usrPwdNonceHash;

Then this hash is returned to the device as:

<Cred>
        <Meta>
              <ns2:Type>syncml:auth-md5</ns2:Type>
              <ns2:Format>b64</ns2:Format>
        </Meta>
        <Data>QpbMtvvfNGRIavJ0jqcxaw==</Data>
</Cred>

But the device returns with a status 401 and a new challenge. Is there something wrong with how i calculate the md5-hash or must there be some other issue?

1

There are 1 answers

0
PKeno On BEST ANSWER

Found my error. The nonce should be the decoded Base64 string value, not the Base64 string.

nonce = new String(Base64.decodeBase64("RLLe7tWM313qHMq9ooUZUPJX0RqU9mEZuyoVF+jXhqQ="), "utf-8");