IKeyAgreementParty.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* IKeyAgreementParty.java --
  2. Copyright (C) 2003, 2006 Free Software Foundation, Inc.
  3. This file is a part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or (at
  7. your option) any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
  15. USA
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package gnu.javax.crypto.key;
  32. import java.util.Map;
  33. /**
  34. * The visible methods of an key agreement protocol participating party.
  35. */
  36. public interface IKeyAgreementParty
  37. {
  38. /**
  39. * Returns the canonical name of the key agreement protocol.
  40. *
  41. * @return the canonical name of the key agreement protocol.
  42. */
  43. String name();
  44. /**
  45. * Sets up the instance to operate with specific attributes.
  46. *
  47. * @param attributes a map of name-values used by concrete implementations.
  48. * @throws KeyAgreementException if an exception occurs during the setup.
  49. */
  50. void init(Map attributes) throws KeyAgreementException;
  51. /**
  52. * Processes an incoming message at one end, generating a message that will be
  53. * processed by the other party(ies).
  54. *
  55. * @param in the incoming message.
  56. * @return an outgoing message, or <code>null</code> if this is an
  57. * intermediary step that does not cause any output.
  58. * @throws KeyAgreementException if an exception occurs during the processing
  59. * of the incoming message, or during the generation of the outgoing
  60. * message.
  61. */
  62. OutgoingMessage processMessage(IncomingMessage in)
  63. throws KeyAgreementException;
  64. /**
  65. * Returns <code>true</code> if the party in the key agreement protocol
  66. * exchange has completed its part of the exchange. If this is the case an
  67. * {@link IllegalStateException} is thrown for any method invocation except
  68. * <code>init()</code> or <code>reset()</code>.
  69. *
  70. * @return <code>true</code> if this party has completed its part of the key
  71. * agreement protocol exchange; <code>false</code> otherwise.
  72. */
  73. boolean isComplete();
  74. /**
  75. * Returns the byte array containing the shared secret as generated by this
  76. * party.
  77. *
  78. * @return the generated shared secret.
  79. * @throws KeyAgreementException if the key agreement is not yet initialised,
  80. * or is initialised but the exchange is still in progress.
  81. */
  82. byte[] getSharedSecret() throws KeyAgreementException;
  83. /** Resets this instance for re-use with another set of attributes. */
  84. void reset();
  85. }