Skip to content

Commit

Permalink
Bug 1304587 - Avoid using types that correspond to char/char16_t stri…
Browse files Browse the repository at this point in the history
…ngs in PKCS mozilla#11 IDL files. r=keeler

Typically, the interfaces involved don't need to use raw char/char16_t strings,
and hence can benefit from the additional safety of using the Mozilla string
classes.

In some places, this patch also changes some UTF-16 APIs to UTF-8 where the
implementations can never actually support UTF-16. This reduces the amount of
code and runtime conversion.

MozReview-Commit-ID: y8o5wLBohe
  • Loading branch information
Cykesiopka committed Sep 30, 2016
1 parent 1fe8b9b commit 8ca090b
Show file tree
Hide file tree
Showing 12 changed files with 182 additions and 288 deletions.
35 changes: 25 additions & 10 deletions security/manager/ssl/nsIPK11Token.idl
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@ interface nsIPK11Token : nsISupports
/*
* The name of the token
*/
readonly attribute wstring tokenName;

readonly attribute wstring tokenLabel;
readonly attribute wstring tokenManID;
readonly attribute wstring tokenHWVersion;
readonly attribute wstring tokenFWVersion;
readonly attribute wstring tokenSerialNumber;
readonly attribute AUTF8String tokenName;
readonly attribute AUTF8String tokenLabel;
/**
* Manufacturer ID of the token.
*/
readonly attribute AUTF8String tokenManID;
/**
* Hardware version of the token.
*/
readonly attribute AUTF8String tokenHWVersion;
/**
* Firmware version of the token.
*/
readonly attribute AUTF8String tokenFWVersion;
readonly attribute AUTF8String tokenSerialNumber;

/*
* Login information
Expand All @@ -42,9 +50,16 @@ interface nsIPK11Token : nsISupports
*/
readonly attribute long minimumPasswordLength;
readonly attribute boolean needsUserInit;
boolean checkPassword(in wstring password); /* Logs out if check fails */
void initPassword(in wstring initialPassword);
void changePassword(in wstring oldPassword, in wstring newPassword);
/**
* Checks whether the given password is correct. Logs the token out if an
* incorrect password is given.
*
* @param password The password to check.
* @return true if the password was correct, false otherwise.
*/
boolean checkPassword(in AUTF8String password);
void initPassword(in AUTF8String initialPassword);
void changePassword(in AUTF8String oldPassword, in AUTF8String newPassword);
long getAskPasswordTimes();
long getAskPasswordTimeout();
void setAskPasswordDefaults([const] in long askTimes, [const] in long timeout);
Expand Down
2 changes: 1 addition & 1 deletion security/manager/ssl/nsIPK11TokenDB.idl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface nsIPK11TokenDB : nsISupports
/*
* Find a token by name
*/
nsIPK11Token findTokenByName(in wstring tokenName);
nsIPK11Token findTokenByName(in AUTF8String tokenName);

/*
* List all tokens
Expand Down
6 changes: 3 additions & 3 deletions security/manager/ssl/nsIPKCS11Module.idl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ interface nsISimpleEnumerator;
[scriptable, uuid(8a44bdf9-d1a5-4734-bd5a-34ed7fe564c2)]
interface nsIPKCS11Module : nsISupports
{
readonly attribute wstring name;
readonly attribute wstring libName;
readonly attribute AUTF8String name;
readonly attribute AUTF8String libName;

nsIPKCS11Slot findSlotByName(in wstring name);
nsIPKCS11Slot findSlotByName(in AUTF8String name);

nsISimpleEnumerator listSlots();
};
4 changes: 2 additions & 2 deletions security/manager/ssl/nsIPKCS11ModuleDB.idl
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ interface nsIPKCS11ModuleDB : nsISupports

nsIPKCS11Module getInternalFIPS();

nsIPKCS11Module findModuleByName(in wstring name);
nsIPKCS11Module findModuleByName(in AUTF8String name);

nsIPKCS11Slot findSlotByName(in wstring name);
nsIPKCS11Slot findSlotByName(in AUTF8String name);

nsISimpleEnumerator listModules();

Expand Down
24 changes: 15 additions & 9 deletions security/manager/ssl/nsIPKCS11Slot.idl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ interface nsIPK11Token;

[scriptable, uuid(c2d4f296-ee60-11d4-998b-00b0d02354a0)]
interface nsIPKCS11Slot : nsISupports {

readonly attribute wstring name;
readonly attribute wstring desc;
readonly attribute wstring manID;
readonly attribute wstring HWVersion;
readonly attribute wstring FWVersion;
readonly attribute AUTF8String name;
readonly attribute AUTF8String desc;
/**
* Manufacturer ID of the slot.
*/
readonly attribute AUTF8String manID;
/**
* Hardware version of the slot.
*/
readonly attribute AUTF8String HWVersion;
/**
* Firmware version of the slot.
*/
readonly attribute AUTF8String FWVersion;

const unsigned long SLOT_DISABLED = 0;
const unsigned long SLOT_NOT_PRESENT = 1;
Expand All @@ -32,7 +40,5 @@ interface nsIPKCS11Slot : nsISupports {
nsIPK11Token getToken();

/* more fun with workarounds - we're referring to everything by token name */
readonly attribute wstring tokenName;

readonly attribute AUTF8String tokenName;
};

Loading

0 comments on commit 8ca090b

Please sign in to comment.