OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 /* | 4 /* |
5 * The following code handles the storage of PKCS 11 modules used by the | 5 * The following code handles the storage of PKCS 11 modules used by the |
6 * NSS. This file is written to abstract away how the modules are | 6 * NSS. This file is written to abstract away how the modules are |
7 * stored so we can decide that later. | 7 * stored so we can decide that later. |
8 */ | 8 */ |
9 #include "secport.h" | 9 #include "secport.h" |
10 #include "prprf.h" | 10 #include "prprf.h" |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 nssutil_freePair(rootFlagsPair); | 760 nssutil_freePair(rootFlagsPair); |
761 return slotString; | 761 return slotString; |
762 } | 762 } |
763 | 763 |
764 | 764 |
765 /************************************************************************ | 765 /************************************************************************ |
766 * Parse Full module specs into: library, commonName, module parameters, | 766 * Parse Full module specs into: library, commonName, module parameters, |
767 * and NSS specifi parameters. | 767 * and NSS specifi parameters. |
768 */ | 768 */ |
769 SECStatus | 769 SECStatus |
| 770 NSSUTIL_ArgParseModuleSpecEx(char *modulespec, char **lib, char **mod, |
| 771 char **parameters, char **nss, |
| 772 char **config) |
| 773 { |
| 774 int next; |
| 775 modulespec = NSSUTIL_ArgStrip(modulespec); |
| 776 |
| 777 *lib = *mod = *parameters = *nss = *config = 0; |
| 778 |
| 779 while (*modulespec) { |
| 780 NSSUTIL_HANDLE_STRING_ARG(modulespec,*lib,"library=",;) |
| 781 NSSUTIL_HANDLE_STRING_ARG(modulespec,*mod,"name=",;) |
| 782 NSSUTIL_HANDLE_STRING_ARG(modulespec,*parameters,"parameters=",;) |
| 783 NSSUTIL_HANDLE_STRING_ARG(modulespec,*nss,"nss=",;) |
| 784 NSSUTIL_HANDLE_STRING_ARG(modulespec,*config,"config=",;) |
| 785 NSSUTIL_HANDLE_FINAL_ARG(modulespec) |
| 786 } |
| 787 return SECSuccess; |
| 788 } |
| 789 |
| 790 /************************************************************************ |
| 791 * Parse Full module specs into: library, commonName, module parameters, |
| 792 * and NSS specifi parameters. |
| 793 */ |
| 794 SECStatus |
770 NSSUTIL_ArgParseModuleSpec(char *modulespec, char **lib, char **mod, | 795 NSSUTIL_ArgParseModuleSpec(char *modulespec, char **lib, char **mod, |
771 char **parameters, char **nss) | 796 char **parameters, char **nss) |
772 { | 797 { |
773 int next; | 798 int next; |
774 modulespec = NSSUTIL_ArgStrip(modulespec); | 799 modulespec = NSSUTIL_ArgStrip(modulespec); |
775 | 800 |
776 *lib = *mod = *parameters = *nss = 0; | 801 *lib = *mod = *parameters = *nss = 0; |
777 | 802 |
778 while (*modulespec) { | 803 while (*modulespec) { |
779 NSSUTIL_HANDLE_STRING_ARG(modulespec,*lib,"library=",;) | 804 NSSUTIL_HANDLE_STRING_ARG(modulespec,*lib,"library=",;) |
780 NSSUTIL_HANDLE_STRING_ARG(modulespec,*mod,"name=",;) | 805 NSSUTIL_HANDLE_STRING_ARG(modulespec,*mod,"name=",;) |
781 NSSUTIL_HANDLE_STRING_ARG(modulespec,*parameters,"parameters=",;) | 806 NSSUTIL_HANDLE_STRING_ARG(modulespec,*parameters,"parameters=",;) |
782 NSSUTIL_HANDLE_STRING_ARG(modulespec,*nss,"nss=",;) | 807 NSSUTIL_HANDLE_STRING_ARG(modulespec,*nss,"nss=",;) |
783 NSSUTIL_HANDLE_FINAL_ARG(modulespec) | 808 NSSUTIL_HANDLE_FINAL_ARG(modulespec) |
784 } | 809 } |
785 return SECSuccess; | 810 return SECSuccess; |
786 } | 811 } |
787 | 812 |
788 /************************************************************************ | 813 /************************************************************************ |
789 * make a new module spec from it's components */ | 814 * make a new module spec from it's components */ |
790 char * | 815 char * |
791 NSSUTIL_MkModuleSpec(char *dllName, char *commonName, char *parameters, | 816 NSSUTIL_MkModuleSpecEx(char *dllName, char *commonName, char *parameters, |
792 » » » » » » » » char *NSS) | 817 » » » » » » » » char *NSS, |
| 818 » » » » » » » » char *config) |
793 { | 819 { |
794 char *moduleSpec; | 820 char *moduleSpec; |
795 char *lib,*name,*param,*nss; | 821 char *lib,*name,*param,*nss,*conf; |
796 | 822 |
797 /* | 823 /* |
798 * now the final spec | 824 * now the final spec |
799 */ | 825 */ |
800 lib = nssutil_formatPair("library",dllName,'\"'); | 826 lib = nssutil_formatPair("library",dllName,'\"'); |
801 name = nssutil_formatPair("name",commonName,'\"'); | 827 name = nssutil_formatPair("name",commonName,'\"'); |
802 param = nssutil_formatPair("parameters",parameters,'\"'); | 828 param = nssutil_formatPair("parameters",parameters,'\"'); |
803 nss = nssutil_formatPair("NSS",NSS,'\"'); | 829 nss = nssutil_formatPair("NSS",NSS,'\"'); |
804 moduleSpec = PR_smprintf("%s %s %s %s", lib,name,param,nss); | 830 if (config) { |
| 831 conf = nssutil_formatPair("config",config,'\"'); |
| 832 moduleSpec = PR_smprintf("%s %s %s %s %s", lib,name,param,nss,conf); |
| 833 nssutil_freePair(conf); |
| 834 } else { |
| 835 moduleSpec = PR_smprintf("%s %s %s %s", lib,name,param,nss); |
| 836 } |
805 nssutil_freePair(lib); | 837 nssutil_freePair(lib); |
806 nssutil_freePair(name); | 838 nssutil_freePair(name); |
807 nssutil_freePair(param); | 839 nssutil_freePair(param); |
808 nssutil_freePair(nss); | 840 nssutil_freePair(nss); |
809 return (moduleSpec); | 841 return (moduleSpec); |
810 } | 842 } |
811 | 843 |
| 844 /************************************************************************ |
| 845 * make a new module spec from it's components */ |
| 846 char * |
| 847 NSSUTIL_MkModuleSpec(char *dllName, char *commonName, char *parameters, |
| 848 char *NSS) |
| 849 { |
| 850 return NSSUTIL_MkModuleSpecEx(dllName, commonName, parameters, NSS, NULL); |
| 851 } |
| 852 |
812 | 853 |
813 #define NSSUTIL_ARG_FORTEZZA_FLAG "FORTEZZA" | 854 #define NSSUTIL_ARG_FORTEZZA_FLAG "FORTEZZA" |
814 /****************************************************************************** | 855 /****************************************************************************** |
815 * Parse the cipher flags from the NSS parameter | 856 * Parse the cipher flags from the NSS parameter |
816 */ | 857 */ |
817 void | 858 void |
818 NSSUTIL_ArgParseCipherFlags(unsigned long *newCiphers,char *cipherList) | 859 NSSUTIL_ArgParseCipherFlags(unsigned long *newCiphers,char *cipherList) |
819 { | 860 { |
820 newCiphers[0] = newCiphers[1] = 0; | 861 newCiphers[0] = newCiphers[1] = 0; |
821 if ((cipherList == NULL) || (*cipherList == 0)) return; | 862 if ((cipherList == NULL) || (*cipherList == 0)) return; |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 value = PR_smprintf("%s" NSSUTIL_PATH_SEPARATOR "%s", | 1149 value = PR_smprintf("%s" NSSUTIL_PATH_SEPARATOR "%s", |
1109 lconfigdir,secmodName); | 1150 lconfigdir,secmodName); |
1110 } else { | 1151 } else { |
1111 value = PR_smprintf("%s",secmodName); | 1152 value = PR_smprintf("%s",secmodName); |
1112 } | 1153 } |
1113 if (configdir) PORT_Free(configdir); | 1154 if (configdir) PORT_Free(configdir); |
1114 return value; | 1155 return value; |
1115 } | 1156 } |
1116 | 1157 |
1117 | 1158 |
OLD | NEW |