Production-ready comparison between byte-array and ByteBuffer
Minor issues in MD_GetHsmInfo()

valueLen = strlen(str); serves no purpose below as the value assigned to valueLen is not used.

int MD_GetHsmInfo(int hsmIndex, int infoType, void *pValue, int valueLen) {
    ...
    valueLen = strlen(str);
    return 0;
}


Perhaps

int MD_GetHsmInfo(int hsmIndex, int infoType, void *pValue, int *valueLen) {
    ...
    *valueLen = strlen(str);
    return 0;
}


or

int MD_GetHsmInfo(int hsmIndex, int infoType, void *pValue, size_t *valueLen) {




Cast not needed

int MD_GetHsmInfo(int hsmIndex, int infoType, void *pValue, int valueLen) {
  ...
  // jbyte *jb = (jbyte*)pValue;
  jbyte *jb = pValue;