In recent years, online social networks (OSNs) have had explosive growth in numbers and popularity. In an OSN, users communicate with each other and share information about themselves. However, limiting the flow of private information across OSNs is very important especially because most OSNs provide insufficient privacy settings to control information leakage. In this paper, we propose a mediated architecture for OSNs that protects users' information from both the OSN provider and unauthorized OSN users. Our proposed approach delegates most of the computation tasks to a semi-trusted proxy server. We exploit a simplified broadcast encryption method in order to design a dynamic, efficient, flexible, and fine-grained (DEFF) control system. In the proposed DEFF system, users are allowed to cryptographically categorize their friends into different relations and to share data with arbitrary groups of them. The results of our analysis indicate that the DEFF system fully protects users' privacy and is very efficient in terms of communication and computation complexities. Copyright © 2012 John Wiley & Sons, Ltd.