#152 Faster generate_Ku function for keytools.c

open
nobody
None
5
2014-08-20
2007-11-15
Anonymous
No

An alternate algorithm to generate_Ku (keytools.c)
http://net-snmp.sourceforge.net/dev/agent/keytools_8c-source.html

[sample code in java]
public static byte[] passphrase2ku(byte[] pass, String algo) {
final int passLen = pass.length;
int bufSize = 2048;
try {
ByteBuffer bytebuf = ByteBuffer.allocate(bufSize+passLen);
MessageDigest digest = MessageDigest.getInstance(algo);

    int i;
    for \(i=0; i<bufSize; i+=passLen\) bytebuf.put\(pass\);
    byte bbuf\[\] = bytebuf.array\(\);
    bufSize = i;

    for \(i=1048576; i>bufSize; i-=bufSize\) digest.update\(bbuf, 0, bufSize\);
    digest.update\(bbuf, 0, i\);
    return \(digest.digest\(\)\);
\}
catch \(Exception e\) \{
    e.printStackTrace\(\);
\}
return null;

}

Discussion

  • Swami J
    Swami J
    2007-11-15

    Logged In: YES
    user_id=1938150
    Originator: NO

    adding submitter id (didnt have an account while submitting this patch)

     
  • Thomas Anders
    Thomas Anders
    2007-11-18

    Logged In: YES
    user_id=848638
    Originator: NO

    Provising sample code in Java doesn't make your suggestion a patch. Until you can provide a patch file for the project, I'm moving it to Feature Requests.