natSimpleSHSStream.cc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // natSimpleSHSStream.cc
  2. /* Copyright (C) 2000 Free Software Foundation
  3. This file is part of libgcj.
  4. This software is copyrighted work licensed under the terms of the
  5. Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
  6. details. */
  7. #include <config.h>
  8. #include <string.h>
  9. #include <stdlib.h>
  10. #include <gnu/gcj/io/SimpleSHSStream.h>
  11. #include <gcj/cni.h>
  12. #include <jvm.h>
  13. #define PROTO
  14. #include "shs.h"
  15. jbyteArray
  16. gnu::gcj::io::SimpleSHSStream::shsFinal (jbyteArray shs_info)
  17. {
  18. SHS_INFO *info = (SHS_INFO *)elements(shs_info);
  19. ::shsFinal (info);
  20. jbyteArray buffer = JvNewByteArray (SHS_DIGESTSIZE);
  21. memcpy (elements (buffer), &info->digest, SHS_DIGESTSIZE);
  22. return buffer;
  23. }
  24. void
  25. gnu::gcj::io::SimpleSHSStream::shsUpdate (jbyteArray shs_info, jbyteArray buf, jint count)
  26. {
  27. SHS_INFO *info = (SHS_INFO *)elements(shs_info);
  28. uint8_t *buffer = (uint8_t *)elements(buf);
  29. ::shsUpdate (info, buffer, count);
  30. }
  31. jbyteArray
  32. gnu::gcj::io::SimpleSHSStream::shsInit ()
  33. {
  34. jbyteArray result = JvNewByteArray (sizeof (SHS_INFO));
  35. SHS_INFO *info = (SHS_INFO *)elements(result);
  36. ::shsInit (info);
  37. return result;
  38. }