In short the answer is unclear, but here are some tips.
Some clients have complained that CBSA officers at Canadian ports of entry ask for passwords to access laptops and cell phones so they can examine text messages and emails. If an officer has some suspicion that the person’s intention is to remain in Canada permanently, the officer can ask many questions to determine motives. This can happen particularly when the person is coming back and forth to visit a fiancée or if there is a desire to spend a greater amount of time together to support a 12 month cohabitation. Emails and text messages can reveal a host of information which may reveal the parties’ true intention.
As a result CBSA officers and immigration officers routinely examine laptop information and or text messages to show the true intention of the parties or individuals. To do so they require passwords.
In a recent case a person was charged with obstruction under the Customs Act for not providing a password. Unfortunately the person did not fight the charge based on constitutional law, but chose to plead guilty instead. So the question remains undecided.
Even in its own internal documents, the CBSA shows ambivalence. By virtue of an Access to Information request received by the BC Civil Liberties Association (https://bccla.org/2016/08/what-happens-if-you-dont-provide-your-cellphone-password-to-border-agents/#.V7-FGmKtR-o.twitter), officers are directed not to arrest individuals for failing to provide passwords. However, they are maintaining the position that they have legal authority to ask for such passwords, but whether they have the right to arrest and convict a person for obstruction in not doing so is a matter that will ultimately be decided by appeal courts when such cases reach that level. In the meantime, if one is asked for a password and does not wish to do so, you can do no better than to provide the following quotation form the Officer’s own guidelines:
Passwords are not to be sought to gain access to any type of account (including any social, professional, corporate, or user accounts), files or information that might potentially be stored remotely or on-line. CBSA officers may only request and make note of passwords required to gain access to information or files if the information or file is known or suspected to exist within the digital device or media being examined.
Conversely, a traveller may voluntarily provide information and passwords to access external data in certain circumstances in order to show compliance; CBSA officers should advise travellers that they are not required to access or provide external information, but may voluntarily choose to do so. The login information or password shall not be compelled or recorded in these cases.
For more information on all of the obligations imposed on officers, see the following manual.
https://bccla.org/wp-content/uploads/2016/08/CBSA-FOI-Docs.pdf
In the end, until the law is decided, it may be best to leave that laptop or cell phone at home!