1. /*
  2. * @(#)file SnmpUsmKeyHandler.java
  3. * @(#)author Sun Microsystems, Inc.
  4. * @(#)version 1.12
  5. * @(#)date 04/09/15
  6. *
  7. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  8. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  9. *
  10. */
  11. package com.sun.jmx.snmp;
  12. /**
  13. * This interface allows you to compute key localization and delta generation. It is useful when adding user in USM MIB. An instance of <CODE> SnmpUsmKeyHandler </CODE> is associated to each <CODE> SnmpEngine </CODE> object.
  14. * When computing key, an authentication algorithm is needed. The supported ones are : usmHMACMD5AuthProtocol and usmHMACSHAAuthProtocol.
  15. * <p><b>This API is a Sun Microsystems internal API and is subject
  16. * to change without notice.</b></p>
  17. * @since 1.5
  18. */
  19. public interface SnmpUsmKeyHandler {
  20. /**
  21. * DES privacy algorithm key size. To be used when localizing privacy key
  22. */
  23. public static int DES_KEY_SIZE = 16;
  24. /**
  25. * DES privacy algorithm delta size. To be used when calculing privacy key delta.
  26. */
  27. public static int DES_DELTA_SIZE = 16;
  28. /**
  29. * Translate a password to a key. It MUST be compliant to RFC 2574 description.
  30. * @param algoName The authentication algorithm to use.
  31. * @param password Password to convert.
  32. * @return The key.
  33. * @exception IllegalArgumentException If the algorithm is unknown.
  34. */
  35. public byte[] password_to_key(String algoName, String password) throws IllegalArgumentException;
  36. /**
  37. * Localize the passed key using the passed <CODE>SnmpEngineId</CODE>. It MUST be compliant to RFC 2574 description.
  38. * @param algoName The authentication algorithm to use.
  39. * @param key The key to localize;
  40. * @param engineId The Id used to localize the key.
  41. * @return The localized key.
  42. * @exception IllegalArgumentException If the algorithm is unknown.
  43. */
  44. public byte[] localizeAuthKey(String algoName, byte[] key, SnmpEngineId engineId) throws IllegalArgumentException;
  45. /**
  46. * Localize the passed privacy key using the passed <CODE>SnmpEngineId</CODE>. It MUST be compliant to RFC 2574 description.
  47. * @param algoName The authentication algorithm to use.
  48. * @param key The key to localize;
  49. * @param engineId The Id used to localize the key.
  50. * @param keysize The privacy algorithm key size.
  51. * @return The localized key.
  52. * @exception IllegalArgumentException If the algorithm is unknown.
  53. */
  54. public byte[] localizePrivKey(String algoName, byte[] key, SnmpEngineId engineId,int keysize) throws IllegalArgumentException;
  55. /**
  56. * Calculate the delta parameter needed when processing key change. This computation is done by the key change initiator. It MUST be compliant to RFC 2574 description.
  57. * @param algoName The authentication algorithm to use.
  58. * @param oldKey The old key.
  59. * @param newKey The new key.
  60. * @param random The random value.
  61. * @return The delta.
  62. * @exception IllegalArgumentException If the algorithm is unknown.
  63. */
  64. public byte[] calculateAuthDelta(String algoName, byte[] oldKey, byte[] newKey, byte[] random) throws IllegalArgumentException;
  65. /**
  66. * Calculate the delta parameter needed when processing key change for a privacy algorithm. This computation is done by the key change initiator. It MUST be compliant to RFC 2574 description.
  67. * @param algoName The authentication algorithm to use.
  68. * @param oldKey The old key.
  69. * @param newKey The new key.
  70. * @param random The random value.
  71. * @param deltaSize The algo delta size.
  72. * @return The delta.
  73. * @exception IllegalArgumentException If the algorithm is unknown.
  74. */
  75. public byte[] calculatePrivDelta(String algoName, byte[] oldKey, byte[] newKey, byte[] random, int deltaSize) throws IllegalArgumentException;
  76. }