In one of several testy exchanges during a U.S. Senate hearing this week, the country's secretary of homeland security was pressed to explain a new policy that allows customs agents to examine the cellphones of travellers at the border.

"I want to make sure I understand this. I live an hour's drive from the Canadian border," said Vermont Sen. Patrick Leahy.

"If I go to Canada and visit some of my wife's relatives, and I come back ... they [can] say, 'We want your laptop and your phone and your pass code.' And I say, 'Well, do you have any reason?' They say, 'We don't need one.' Is that correct? They can do that?"

"Welcome to America," Leahy added sarcastically.

Secretary Kirstjen Nielsen explained some of what the new policy does and doesn't do. Some key details:

—Background: Searches of phones were skyrocketing. Border agents inspected 30,200 phones and other devices last year — an increase of nearly 60 per cent from 2016. U.S. officials say it remains a minuscule percentage of overall travellers — 0.007 per cent, or roughly one per 13,000. The Department of Homeland Security says it's necessary to combat crimes like terrorism and child pornography.

—Customs agents have broad power: Immigration lawyer Henry Chang notes that one of his own colleagues once complained about a search, fearing a breach of attorney-client privilege: "The officer said, 'I don't care,"' Chang says. He said border guards can easily refuse someone entry: "There's ways they can mess with you," he said. "They can just declare you an immigration risk ... detain you, turn you away until you co-operate.... That's enough to scare people into co-operating."

Border agents inspected 30,200 phones and other devices last year — an increase of nearly 60 per cent from 2016. (Elaine Thompson/The Associated Press)

—The new directive: On Jan. 4, U.S. Customs and Border Protection issued a new directive titled, Border Search of Electronic Devices. It actually set new limits on agents, establishing criteria for when they can conduct extensive searches, like downloading documents stored in the cloud, or uploading files into a storage drive for analysis.

—Your password: Agents can demand a password to open your phone, without probable cause, Nielsen confirmed during the hearing. However, Electronic Frontier Foundation (EFF) staff attorney Sophia Cope says the directive, which she calls confusing, also allows you to refuse to do so. That, of course, is not without its consequences she says in a statement to CBC News. Your device could be seized or detained. The border agent could delay your travel or even deny entry if you are not a U.S. citizen.

—The cloud: Here, there are new limits. Agents can't just start downloading old files from the cloud: "They can search the data that is apparent on the phone," Nielsen said. "They can't use the phone to access anything that might be stored remotely."

—Airplane mode: Officers are supposed to ask travellers to shut off their signal. That's to ensure remote files don't get downloaded accidentally. If warranted by security concerns, the Jan. 4 directive says officers can themselves perform the task of shutting off connectivity.

To ensure remote files don't get downloaded accidentally, border agents should place devices in airplane mode, or turn off mobile data and Wi-Fi. Travellers may want to turn off their phones before border inspections. (Lucas Jackson/Reuters)

—Advanced search: An officer may judge it necessary for national security purposes, such as cases where the traveller is on a watch list, to connect a phone to a hard drive, then copy its contents for analysis. The directive says this requires the approval of a certain rank of supervisor.

—Detention: If they can't access a device, officers can detain it for a multi-day period. Detentions beyond five days must be approved by management. To detain a device, officers must fill out a form.

—Sensitive info: Lawyers can claim attorney-client privilege, citing which specific files are sensitive, and the officer must consult with customs legal counsel and the U.S. attorney's office to determine which files should be isolated from the regular search. Medical records, proprietary business information and journalists' notes must be handled in accordance with U.S. law, like privacy and trade-secrets legislation.

—Accountability: Travellers can be present during a search, though they can't ask to see the screen. Travellers must be notified of the purpose for a search. There are national-security exceptions on those rights. But travellers must be given information on where they can complain. Searches must be documented, with statistics kept and regularly published. Regular audits must keep track of whether agents are following rules.

A traveller talks to a U.S. Customs and Border Protection official near the exit of the international arrivals terminal at Newark Liberty International Airport on Oct. 26, 2017, in Newark, N.J. (Julio Cortez/Associated Press)

—Destruction of records: Any copies of information held by U.S. customs must be destroyed, and any electronic device returned — unless there's a security threat and probable cause for an exception.

—So what to do: Chang offers three pieces of advice — before crossing the border, delete private material or transfer it to the cloud; at the border, turn on airplane mode yourself; and, finally, be prepared, unless you have some really compelling privacy reason, to just turn over your phone.

"You've got to choose your battles," he said.

Border agents cannot stop U.S. citizens from entering the country, even if they refuse to unlock their device or provide the password. However, EFF says, "agents may escalate the encounter if you refuse. For example, agents may seize your devices, ask you intrusive questions, search your bags more intensively, or increase by many hours the length of detention."

If a foreign visitor doesn't comply, agents may deny them entry, EFF says.