Knox Tizen Wearable SDK
security.h
1 /*
2  * Copyright (c) 2000-2017 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * PROPRIETARY/CONFIDENTIAL
5  *
6  * This software is the confidential and proprietary information of
7  * SAMSUNG ELECTRONICS ("Confidential Information").
8  * You shall not disclose such Confidential Information and shall
9  * use it only in accordance with the terms of the license agreement
10  * you entered into with SAMSUNG ELECTRONICS.
11  * SAMSUNG make no representations or warranties about the suitability
12  * of the software, either express or implied, including but not
13  * limited to the implied warranties of merchantability, fitness for
14  * a particular purpose, or non-infringement.
15  * SAMSUNG shall not be liable for any damages suffered by licensee as
16  * a result of using, modifying or distributing this software or its derivatives.
17  */
18 
19 #ifndef LIBMDM_MDM_SECURITY_H
20 #define LIBMDM_MDM_SECURITY_H
21 
22 #include "mdm_client_type.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
39 typedef enum {
42 } mdm_wipe_t;
43 
59 typedef enum {
65 
81 typedef struct {
82  char *countryName;
84  char *localityName;
87  char *commonName;
88  char *emailAddress;
90 
106 typedef struct {
108  int enabled;
109  int version;
111  char * sigAlgo;
112  char * issuerStr;
114  char * subjectStr;
116  char * pubKeyAlgo;
117  char * pubKey;
118  char * issuerUID;
119  char * subjectUID;
120  char * alias;
122 
123 
168 
209 mdm_result_t mdm_wipe_data(mdm_wipe_t type);
210 
250 
304 mdm_result_t mdm_install_certificate(mdm_certificate_t type, const char *file_path, const char *name,
305  const char *password);
306 
366 
401 
402 /*
403  * @brief API to encrypt external storage.
404  *
405  * @since_mdm 1.0.0
406  *
407  * @since_tizen 2.3.2.3
408  *
409  * @feature %http://developer.samsung.com/tizen/feature/mdm
410  *
411  * @par Usage:
412  * Admin can enable external sd card encryption if any.
413  *
414  * @code{.c}
415  mdm_result_t ret = 0;
416  ret = mdm_set_external_storage_encryption(MDM_TRUE);
417  if (ret == MDM_RESULT_SUCCESS) {
418  // encrypting success
419  } else {
420  // encrypting fail
421  }
422  *
423  * @endcode
424  *
425  * @privlevel public
426  * @privilege %http://developer.samsung.com/tizen/privilege/mdm.security
427  *
428  * @param[in] value #MDM_FALSE: Disable external storage encryption.\n
429  * #MDM_TRUE: Enable external storage encryption.
430  *
431  * @return #mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
432  *
433  * @retval #MDM_RESULT_SUCCESS Successful
434  * @retval #MDM_RESULT_FAIL General failure
435  * @retval #MDM_RESULT_NOT_SUPPORTED Not supported
436  * @retval #MDM_RESULT_INVALID_PARAM Invalid parameter
437  * @retval #MDM_RESULT_ACCESS_DENIED The application does not have the privilege to call this function.
438  *
439  * @par Permission:
440  * Usage of this API is restricted to registered clients only.
441  *
442  * @see mdm_get_external_storage_encryption_status
443  *
444  */
445 mdm_result_t mdm_set_external_storage_encryption(mdm_status_t value);
446 
447 /*
448  * @brief This API returns status of the external storage encryption state.
449  *
450  * @since_mdm 1.0.0
451  *
452  * @since_tizen 2.3.1.5
453  *
454  * @feature %http://developer.samsung.com/tizen/feature/mdm
455  *
456  * @par Usage:
457  * Admin can check whether external storage encryption is enabled or not.
458  * @code{.c}
459  mdm_status_t status = MDM_TRUE;
460  status = mdm_get_external_storage_encryption_status();
461  if (status == MDM_STATUS_ERROR) {
462  // function error
463  } else {
464  // function success
465  }
466  *
467  * @endcode
468  *
469  * @return #mdm_status_t : #MDM_TRUE or #MDM_FALSE on success, an error code on error
470  *
471  * @see mdm_set_external_storage_encryption
472  *
473  */
474 mdm_status_t mdm_get_external_storage_encryption_status(void);
475 
476 /*
477  * @brief API to allow or restrict internet sharing.
478  *
479  * @since_mdm 1.0.0
480  *
481  * @since_tizen 2.3.2.3
482  *
483  * @feature %http://developer.samsung.com/tizen/feature/mdm
484  *
485  * @par Usage:
486  * Admin can disable the internet sharing.
487  * @code{.c}
488  mdm_result_t ret = MDM_RESULT_SUCCESS;
489  ret = mdm_set_allow_internet_sharing(MDM_RESTRICTED);
490  if (ret == MDM_RESULT_SUCCESS) {
491  // setting success
492  } else {
493  // setting fail
494  }
495  *
496  * @endcode
497  *
498  * @privlevel public
499  * @privilege %http://developer.samsung.com/tizen/privilege/mdm.security
500  * @param[in] value #MDM_RESTRICTED: Disables internet sharing, user cannot enable.\n
501  * #MDM_ALLOWED: user control restored but will not enable it.
502  *
503  * @return #mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
504  *
505  * @retval #MDM_RESULT_SUCCESS Successful
506  * @retval #MDM_RESULT_FAIL General failure
507  * @retval #MDM_RESULT_NOT_SUPPORTED Not supported
508  * @retval #MDM_RESULT_INVALID_PARAM Invalid parameter
509  * @retval #MDM_RESULT_ACCESS_DENIED The application does not have the privilege to call this function.
510  *
511  * @par Permission:
512  * Usage of this API is restricted to registered clients only.
513  *
514  * @see mdm_get_allow_internet_sharing
515  *
516  */
517 mdm_result_t mdm_set_allow_internet_sharing(mdm_status_t value);
518 
519 /*
520  * @brief API to check if internet sharing is allowed or restricted.
521  *
522  * @since_mdm 1.0.0
523  *
524  * @since_tizen 2.3.1.5
525  *
526  * @feature %http://developer.samsung.com/tizen/feature/mdm
527  *
528  * @par Usage:
529  * Admin can check if internet sharing is allowed or restricted.
530  * @code{.c}
531  mdm_status_t status = MDM_ALLOWED;
532  status = mdm_get_allow_internet_sharing();
533  if (status == MDM_STATUS_ERROR) {
534  // function error
535  } else {
536  // function success
537  }
538  *
539  * @endcode
540  *
541  * @return #mdm_status_t : The current prevention status.
542  *
543  * @retval #MDM_ALLOWED Allowed
544  * @retval #MDM_RESTRICTED Restricted
545  *
546  * @see mdm_set_allow_internet_sharing
547  *
548  */
549 mdm_status_t mdm_get_allow_internet_sharing(void);
550 
551 /*
552  * @brief API to allow or restrict desktop sync.
553  *
554  * @since_mdm 1.0.0
555  *
556  * @since_tizen 2.3.2.3
557  *
558  * @feature %http://developer.samsung.com/tizen/feature/mdm
559  *
560  * @par Usage:
561  * Admin can allow or restrict the desktop sync.
562  *
563  * @remark
564  * Desktop sync restriction #mdm_status_t is written to #MDM_POLICY_ON_KIES notification file.
565  * You can register a callback for this event using #mdm_register_policy_receiver.
566  *
567  * @code{.c}
568  mdm_result_t ret = MDM_RESULT_SUCCESS;
569  ret = mdm_set_allow_desktop_sync(MDM_RESTRICTED);
570  if (ret == MDM_RESULT_SUCCESS) {
571  // setting success
572  } else {
573  // setting fail
574  }
575  *
576  * @endcode
577  *
578  * @privlevel public
579  * @privilege %http://developer.samsung.com/tizen/privilege/mdm.security
580  *
581  * @param[in] value #MDM_RESTRICTED: Disables desktop sync, user cannot enable.\n
582  * #MDM_ALLOWED: user control restored but will not enable it.
583  *
584  * @return #mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
585  *
586  * @retval #MDM_RESULT_SUCCESS Successful
587  * @retval #MDM_RESULT_FAIL General failure
588  * @retval #MDM_RESULT_NOT_SUPPORTED Not supported
589  * @retval #MDM_RESULT_INVALID_PARAM Invalid parameter
590  * @retval #MDM_RESULT_ACCESS_DENIED The application does not have the privilege to call this function.
591  *
592  * @par Permission:
593  * Usage of this API is restricted to registered clients only.
594  *
595  * @see mdm_get_allow_desktop_sync
596  *
597  */
598 mdm_result_t mdm_set_allow_desktop_sync(mdm_status_t value);
599 
600 /*
601  * @brief API to check if desktop sync is allowed or restricted.
602  *
603  * @since_mdm 1.0.0
604  *
605  * @since_tizen 2.3.1.5
606  *
607  * @feature %http://developer.samsung.com/tizen/feature/mdm
608  *
609  * @par Usage:
610  * Admin can check if the desktop sync is allowed or restricted.
611  * @code{.c}
612  mdm_status_t status = MDM_ALLOWED;
613  status = mdm_get_allow_desktop_sync();
614  if (status == MDM_STATUS_ERROR) {
615  // function error
616  } else {
617  // function success
618  }
619  *
620  * @endcode
621  *
622  * @return #mdm_status_t : The current prevention status.
623  *
624  * @retval #MDM_ALLOWED Allowed
625  * @retval #MDM_RESTRICTED Restricted
626  *
627  * @see mdm_set_allow_desktop_sync
628  *
629  */
630 mdm_status_t mdm_get_allow_desktop_sync(void);
631 
681 
761 
828 
880 
881 /*
882  * @brief API to check the policy of internal storage encryption.
883  *
884  * @since_mdm 1.0.0
885  *
886  * @since_tizen 2.3.1.5
887  *
888  * @feature %http://developer.samsung.com/tizen/feature/mdm
889  *
890  * @par Usage:
891  * Invoking this function, admin can check if internal encryption is restricted or not.
892  * It returns value set by #mdm_set_require_device_encryption.
893  *
894  * @code{.c}
895 
896  mdm_status_t stat = mdm_get_require_device_encryption();
897  if (stat == MDM_FALSE || stat == MDM_TRUE) {
898 
899  if (stat == MDM_TRUE) {
900 
901  ret = mdm_set_internal_storage_encryption(MDM_TRUE);
902  if (ret == MDM_RESULT_SUCCESS) {
903  // function success
904  } else {
905  // function error
906  }
907 
908  } else {
909  // Internal storage encryption is restricted.
910  }
911  } else {
912  // function error
913  }
914 
915  * @endcode
916  *
917  * @return #mdm_status_t : Current mode of operation, one of #MDM_FALSE or #MDM_TRUE.
918  * #MDM_STATUS_ERROR if error occured.
919  *
920  * @see mdm_set_require_device_encryption
921  * @see mdm_set_internal_storage_encryption
922  *
923  */
924 mdm_status_t mdm_get_require_device_encryption(void);
925 
926 /*
927  * @brief API to check if the storage card encryption is required on device.
928  *
929  * @since_mdm 1.0.0
930  *
931  * @since_tizen 2.3.1.5
932  *
933  * @feature %http://developer.samsung.com/tizen/feature/mdm
934  *
935  * @par Usage:
936  * Admin can check whether given admin has requested for SD Card encryption or not. Based on this value enterprise can
937  take some action.
938  *
939  * @code{.c}
940  mdm_status_t status = MDM_ALLOWED;
941  status = mdm_get_require_storage_card_encryption();
942  if (status == MDM_STATUS_ERROR) {
943  // function error
944  } else {
945  // function success
946  }
947  *
948  * @endcode
949  *
950  * @return #mdm_status_t : Current mode of operation, one of #MDM_ALLOWED or #MDM_RESTRICTED
951  *
952  * @see mdm_set_require_storage_card_encryption
953  *
954  */
955 mdm_status_t mdm_get_require_storage_card_encryption(void);
956 
957 /*
958  * @brief API to allow/disallow for internal storage encryption.
959  *
960  * @since_mdm 1.0.0
961  *
962  * @since_tizen 2.3.2.3
963  *
964  * @feature %http://developer.samsung.com/tizen/feature/mdm
965  *
966  * @par Usage:
967  * Admin may use this API to allow/disallow calling of #mdm_set_internal_storage_encryption. It means:
968  * - If the policy is set to #MDM_TRUE, user is allowed to run encrypting application by calling of
969  #mdm_set_internal_storage_encryption.
970  * - If the policy is set to #MDM_FALSE, calls of #mdm_set_internal_storage_encryption cannot run encrypting
971  application.
972  *
973  * This restriction concerns only internal storage encryption, for external storage use
974  #mdm_set_require_storage_card_encryption.
975  *
976  * @code{.c}
977 
978  mdm_result_t ret = mdm_set_require_device_encryption(MDM_TRUE);
979  if (ret == MDM_RESULT_SUCCESS) {
980 
981  ret = mdm_set_internal_storage_encryption(MDM_TRUE);
982  if (ret == MDM_RESULT_SUCCESS) {
983  // function success
984  } else {
985  // function error
986  }
987 
988  } else {
989  // function error
990  }
991 
992  * @endcode
993  *
994  * @privlevel public
995  * @privilege %http://developer.samsung.com/tizen/privilege/mdm.security
996  *
997  * @param[in] value #MDM_TRUE to enable encryption, #MDM_FALSE to disable it.
998  *
999  * @return #mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
1000  *
1001  * @retval #MDM_RESULT_SUCCESS Successful
1002  * @retval #MDM_RESULT_FAIL General failure
1003  * @retval #MDM_RESULT_NOT_SUPPORTED Not supported
1004  * @retval #MDM_RESULT_INVALID_PARAM Invalid parameter
1005  * @retval #MDM_RESULT_ACCESS_DENIED The application does not have the privilege to call this function.
1006  *
1007  * @par Permission:
1008  * Usage of this API is restricted to registered clients only.
1009  *
1010  * @see mdm_get_require_device_encryption
1011  * @see mdm_set_internal_storage_encryption
1012  *
1013  */
1014 mdm_result_t mdm_set_require_device_encryption(mdm_status_t value);
1015 
1016 /*
1017  * @brief API used to check if storage card encryption is required or not.
1018  *
1019  * @since_mdm 1.0.0
1020  *
1021  * @since_tizen 2.3.2.3
1022  *
1023  * @feature %http://developer.samsung.com/tizen/feature/mdm
1024  *
1025  * @par Usage:
1026  * This API is used to check if storage card encryption is required or not.
1027  *
1028  * @code{.c}
1029  mdm_result_t ret = 0;
1030  int n_status = MDM_RESTRICTED;
1031 
1032  ret = mdm_set_require_storage_card_encryption(n_status);
1033  if (ret == MDM_STATUS_ERROR) {
1034  // function error
1035  } else {
1036  // function success
1037  }
1038  *
1039  * @endcode
1040  *
1041  * @privlevel public
1042  * @privilege %http://developer.samsung.com/tizen/privilege/mdm.security
1043  *
1044  * @param[in] value True to enable encryption, false to disable.
1045  *
1046  * @return #mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
1047  *
1048  * @retval #MDM_RESULT_SUCCESS Successful
1049  * @retval #MDM_RESULT_FAIL General failure
1050  * @retval #MDM_RESULT_NOT_SUPPORTED Not supported
1051  * @retval #MDM_RESULT_INVALID_PARAM Invalid parameter
1052  * @retval #MDM_RESULT_ACCESS_DENIED The application does not have the privilege to call this function.
1053  *
1054  * @par Permission:
1055  * Usage of this API is restricted to registered clients only.
1056  *
1057  * @see mdm_get_require_storage_card_encryption
1058  *
1059  */
1060 mdm_result_t mdm_set_require_storage_card_encryption(mdm_status_t value);
1061 
1062 /*
1063  * @brief API to get a list of the filenames on the device.
1064  *
1065  * @since_mdm 1.0.0
1066  *
1067  * @since_tizen 2.3.1.5
1068  *
1069  * @feature %http://developer.samsung.com/tizen/feature/mdm
1070  *
1071  * @par Usage:
1072  * It will return all directory content for a specific path. If path is not specified it will return all files on root.
1073  *
1074  * @code{.c}
1075  mdm_result_t ret = 0;
1076  mdm_data_t *lp_data = mdm_get_file_names_on_device("/root");
1077  if (lp_data) {
1078  GList *lp_list = (GList *)lp_data->data;
1079  if (lp_list) {
1080  lp_list = g_list_first(lp_list);
1081 
1082  while (lp_list && lp_list->data) {
1083  printf("file name : %s", lp_list->data);
1084  lp_list = g_list_next(lp_list);
1085  }
1086  }
1087  mdm_free_data(lp_data);
1088  ret = MDM_RESULT_SUCCESS;
1089  } else {
1090  ret = MDM_RESULT_FAIL;
1091  }
1092  *
1093  * @endcode
1094  *
1095  * @param[in] p_path The file path in device.
1096  *
1097  * @return #mdm_data_t * on success, NULL on error
1098  *
1099  * @see mdm_get_file_names_with_attributes
1100  *
1101  */
1102 mdm_data_t *mdm_get_file_names_on_device(char *p_path);
1103 
1104 /*
1105  * @brief API to get a detailed list of files on device.
1106  *
1107  * @since_mdm 1.0.0
1108  *
1109  * @since_tizen 2.3.1.5
1110  *
1111  * @feature %http://developer.samsung.com/tizen/feature/mdm
1112  *
1113  * @par Usage:
1114  * It will return all directory content for a specific path. If path is not specified it will return all files on root.
1115  * The output content will have: permission, owner, group, date, time andd file name.
1116  *
1117  * @code{.c}
1118  mdm_result_t ret = 0;
1119  mdm_data_t *lp_data = mdm_get_file_names_with_attributes("/root");
1120  if (lp_data) {
1121  GList *lp_list = (GList *)lp_data->data;
1122  if (lp_list) {
1123  lp_list = g_list_first(lp_list);
1124 
1125  while (lp_list && lp_list->data) {
1126  printf("Attribute : %s", lp_list->data);
1127  lp_list = g_list_next(lp_list);
1128  }
1129  }
1130  mdm_free_data(lp_data);
1131  ret = MDM_RESULT_SUCCESS;
1132  } else {
1133  ret = MDM_RESULT_FAIL;
1134  }
1135 
1136  *
1137  * @endcode
1138  *
1139  * @param[in] p_path The file path in device.
1140  *
1141  * @return #mdm_data_t * on success, NULL on error
1142  *
1143  * @see mdm_get_file_names_on_device
1144  *
1145  */
1146 mdm_data_t *mdm_get_file_names_with_attributes(char *p_path);
1147 
1190 
1191 /*
1192  * @brief API to update the firmware of device.
1193  *
1194  * @since_mdm 1.0.0
1195  *
1196  * @since_tizen 2.3.2.3
1197  *
1198  * @feature %http://developer.samsung.com/tizen/feature/mdm
1199  *
1200  * @par Usage:
1201  * Admin can use the firmware update api immediately.
1202  * @code{.c}
1203  mdm_result_t ret = mdm_update_firmware_in_device();
1204  if (ret == MDM_RESULT_SUCCESS) {
1205  // success to update firmware
1206  } else {
1207  // fail to update firmware
1208  }
1209  *
1210  * @endcode
1211  *
1212  * @privlevel public
1213  * @privilege %http://developer.samsung.com/tizen/privilege/mdm.security
1214  *
1215  * @return #mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
1216  *
1217  * @retval #MDM_RESULT_SUCCESS Successful
1218  * @retval #MDM_RESULT_FAIL General failure
1219  * @retval #MDM_RESULT_NOT_SUPPORTED Not supported
1220  * @retval #MDM_RESULT_INVALID_PARAM Invalid parameter
1221  * @retval #MDM_RESULT_ACCESS_DENIED The application does not have the privilege to call this function.
1222  *
1223  * @par Permission:
1224  * Usage of this API is restricted to registered clients only.
1225  *
1226  */
1227 mdm_result_t mdm_update_firmware_in_device(void);
1228 
1267 
1313 
1352 
1357 #ifdef __cplusplus
1358 }
1359 #endif
1360 
1361 #endif // LIBMDM_MDM_SECURITY_H
mdm_result_t knox_mdm_set_allow_lockscreen_type_change(mdm_status_t status)
API to allow or restrict changes to the lock screen type.
Certificate filed data.
Definition: security.h:106
char * stateOrProvinceName
Definition: security.h:83
This structure is used to store GList.
mdm_result_t mdm_lock_now(void)
API to immediately lock the device screen.
Certificate name filed data.
Definition: security.h:81
mdm_wipe_t
Device wipe type.
Definition: security.h:39
mdm_status_t knox_mdm_get_allow_lockscreen_type_change(void)
API to check if changing the lock screen type is allowed.
char * organizationUnitName
Definition: security.h:86
mdm_status_t
MDM Policy status.
mdm_data_t * mdm_get_installed_certificate_names(mdm_certificate_t type)
API returns a list of certificate names currently installed on a device. The names included in the li...
mdm_data_t * mdm_get_installed_certificates(mdm_certificate_t type)
API returns a list of user certificates currently installed on a device.
security_name_fld_data issuer
Definition: security.h:113
mdm_result_t mdm_power_off_device(void)
API to power off the device.
mdm_result_t mdm_wipe_data(mdm_wipe_t type)
API to erase the device's external or internal storage.
mdm_result_t mdm_remove_certificate(mdm_certificate_t type, const char *name)
API to remove certificate authority (CA) or user certificates on a device.
security_name_fld_data subject
Definition: security.h:115
mdm_certificate_t storeType
Definition: security.h:107
mdm_status_t mdm_get_internal_storage_encryption_status(void)
API checks the status of internal storage encryption on device.
mdm_result_t mdm_set_internal_storage_encryption(mdm_status_t value)
API to encrypt / decrypt internal storage.
mdm_result_t
MDM API result.
mdm_result_t mdm_install_certificate(mdm_certificate_t type, const char *file_path, const char *name, const char *password)
API to install certificates on a device.
mdm_status_t mdm_get_lock_state(void)
API to get the current status of lock screen. Checks if lock screen is locked, or unlocked...
mdm_result_t mdm_reboot(void)
API to reboot the device immediately.
mdm_result_t mdm_clear_installed_certificates(mdm_certificate_t type)
API to remove all installed certificates from the device.
mdm_certificate_t
Certificate type.
Definition: security.h:59