hex-encoding of recipient ids results in different values (smp vs. accespoint)

given the recipient id 0010:1973031500000 the smp encodes this to http://B-bdecb34bc8a0af41465345086f6e50a7.busdox-actorid-upis.sml1.smloc... but the AP calculates a slightly different value of http://B-bdecb34bc8a0af4146534586f6e50a7.busdox-actorid-upis.sml1.smloc.org (there is a "0" missing in the middle)! this results in an dns lookup failure! We are using the reference implementations V 1.0 We compared the source code of the encodings and found differences in the hex-encoding algorithm. impl. in AP: MessageDigest algorithm = MessageDigest.getInstance("MD5"); algorithm.reset(); algorithm.update(defaultBytes); byte messageDigest[] = algorithm.digest(); StringBuffer hexString = new StringBuffer(); for (int i = 0; i < messageDigest.length; i++) { hexString.append(Integer.toHexString(0xFF & messageDigest[i])); } String foo = messageDigest.toString(); System.out.println("sessionid " + source + " md5 version is " + hexString.toString()); source = hexString + ""; return source; impl: in SMP: private static String convertServiceGroupToURI(ServiceGroupId serviceGroupId) { MessageDigest md; try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { throw new ExceptionInInitializerError(e); } md.update(serviceGroupId.getBusinessIdentifier().getBytes()); byte[] digest = md.digest(); String hashedIdentifier = new String(Hex.encodeHex(digest)); String url = "http://" + HASHED_IDENTIFIER_PREFIX + hashedIdentifier + "." + serviceGroupId.getIdentifierScheme() + "." + SML_DOMAIN; return url; }



HardwareNone
ProductJava START
Operating SystemAll
ComponentAccess Point
Versionv1.10
Severitycritical
ResolutionFixed

Category

Bugs

Comments

Wed, 18/08/2010 - 10:15

The Implementation of the AP with the mentioned problem was in the trunk version but not in the tagged version (in beginning of july).

Wed, 18/08/2010 - 10:17

This is an error in the AP ( MetadatapublisherClient.java - busdox-transport-commons) The implementation must be: private String md5sum(String source) throws NoSuchAlgorithmException { byte[] defaultBytes = source.getBytes(); MessageDigest algorithm = MessageDigest.getInstance("MD5"); algorithm.reset(); algorithm.update(defaultBytes); byte messageDigest[] = algorithm.digest(); StringBuffer hexString = new StringBuffer(); for (int i = 0; i < messageDigest.length; i++) { String hex = Integer.toHexString(0xFF & messageDigest[i]); if (hex.length() == 1) { hexString.append('0'); } hexString.append(hex); } return hexString.toString(); }

Mon, 10/01/2011 - 12:05

Assigned to me. Now there is a common place in eu.peppol.busdox.uri.BusdoxURLUtils#getDNSNameOfParticipant to calculate the DNS name from a participant identifier in the correct way

Login or create an account to comment.