In late 2015, the U.S. Federal Bureau of Investigation (FBI) seized the iPhone of a shooter involved in a terrorist attack in San Bernadino, California. The problem? The phone was locked, and Apple refused all FBI demands to unlock it. In no time, the aftermath of a violent crime was followed by an unexpectedly furious discourse over cell phone privacy. The case finally ended when the phone was unlocked by a paid group of professional hackers. But the debate continued.

Now, in 2018, it doesn’t necessarily take a group of hackers to unlock a phone. In fact, law enforcement might only need a small 4×4″ device and two lightning cables to do the job — oh, and $15-30,000 USD. A recent investigation by VICE Motherboard discovered that law enforcement agencies all over the U.S. (including the Secret Service and State Department) are investing in this device, called GrayKey, that can crack open both password or fingerprint-protected iPhones. Motherboard also identified multiple regional and local police forces who have purchased the device.

For $15,000, law enforcement gets 300 unlocks with online connectivity, or, for $30,000 they can open an unlimited number of phones and work offline. Forbes reports the system works with models up to the most recent iPhone model, the X, though it is unclear if the system works with the new model’s facial recognition lock.

It may be a good time to note there is some legal precedent for when police can and cannot search and seize your mobile device – whether a cell phone, tablet, or personal computer. Given that it’s become increasingly common, here’s what you should know. (And just a quick reminder: Futurism is not a legal organization and this piece was neither written nor edited by legal experts.)

1. If you give consent

If you’re involved with police in any way, they may ask to conduct a search of your apartment, car, or personal possessions. If you give consent, according to the Electronic Freedom Foundation (EFF), the police can also search your mobile devices. That’s also the case if the police stop by your place when you’re not home, and your roommate tells them it’s cool. This same is true at your place of work, where your employer can give police permission to search your office or workspace in your absence.

If you consent for the police to search your home or property, you can limit the scope of that search by refusing to hand over your phone. Additionally, you are not required to give law enforcement the passcode or encryption key for your devices. That’s because your passcode falls under your Fifth Amendment rights, which state you can’t be forced to give self-incriminating testimony. There are some cases where a judge can force you to hand over access, but if you’re in that situation, you definitely should have sought legal counsel a long time ago.

2. If they have a warrant

A warrant to search your possessions should include the items the police are seizing, so your mobile devices need to be on that list. However, the police can take a phone or computer without a warrant if it’s on and displaying something clearly illegal. You also are not required to answer questions or help the police in a warrant-permitted search; in that case, EFF recommends the best thing to do is simply say: “I do not want to talk to you. I do not consent to a search. I want to speak to my attorney.”

3. If you’re arrested

If, heaven forbid, law enforcement has some reason to take you in for arrest, police can remove anything on your person –including your mobile devices. However, the Supreme Court ruled that police can’t search the contents of a device without a warrant; all they can do is physically search the device, including removing the phone from the case or removing the battery.

4. If there’s an imminent threat evidence will be destroyed

Courts have long upheld that police can seize property without a warrant if it looks as though someone is about to destroy property that could serve as evidence in an investigation. This standard has been extended to cell phones, most recently by a Florida circuit court. However, this case also emphasized the rights of the cell phone owner, stating that a police officer must provide reasonable proof that evidence is at risk.

5. If you’re crossing a border

Between 2015 and 2017, U.S. airports saw searches of electronic devices rise more than 70 percent. That’s because U.S. Customs and Borders Protection agents have wide latitude in searching electronic devices at any U.S. border (and technically, any airport constitutes a border). These searches don’t require a warrant or even evidence that you’ve done anything illegal, and can even include demands to hand over your passcode. This latitude might not last forever, though; the ACLU is currently pursuing a lawsuit demanding the government explain the policies around these searches, particularly as they apply to domestic passengers.

In all of the above situations, be aware that it’s always possible that police will deny you have these rights, or simply not be aware of the law surrounding electronic devices. After all, the law moves relatively slowly compared to tech, and not everyone can keep up. In these situations, it’s best to keep cool and to continue emphasizing what you believe to be your rights.